Jefffrey commented on code in PR #12397:
URL: https://github.com/apache/arrow-rs/pull/12397#discussion_r4656735492
##########
arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs:
##########
@@ -202,9 +202,7 @@ impl<K> FixedSizeBinaryDictionaryBuilder<K>
where
K: ArrowDictionaryKeyType,
{
- fn get_or_insert_key(&mut self, value: impl AsRef<[u8]>) ->
Result<K::Native, ArrowError> {
- let value_bytes: &[u8] = value.as_ref();
-
+ fn get_or_insert_key(&mut self, value_bytes: &[u8]) -> Result<K::Native,
ArrowError> {
Review Comment:
the 'hole' is that it could be feasible for an implementation of
`AsRef<[u8]>` to actually return two different values in subsequent calls, in a
safe way. so we need to ensure we call it only once, and then pass through
`&[u8]` which is now safe to handle, as passing through `impl AsRef<[u8]>`
gives control over to the implementation
a nice side effect is that i find this to just be cleaner, and we no longer
need to make `get_or_insert_key` generic over `impl AsRef<[u8]>`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]