You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "chaokunyang (via GitHub)" <gi...@apache.org> on 2025/10/15 02:40:14 UTC

Re: [PR] perf(Rust): remove clone()/to_owned() on MetaString/MetaStringBytes in MetaStringResolver to improve performance [fory]

chaokunyang commented on code in PR #2769:
URL: https://github.com/apache/fory/pull/2769#discussion_r2430960019


##########
rust/fory-core/src/resolver/metastring_resolver.rs:
##########
@@ -130,48 +133,46 @@ impl MetaStringWriterResolver {
         }
     }
 
-    pub fn get_or_create_meta_string_bytes(&mut self, m: &MetaString) -> MetaStringBytes {
-        if let Some(b) = self.meta_string_to_bytes.get(m) {
-            return b.clone();
-        }
-        let bytes = m.bytes.to_vec();
-        let hash_code = murmurhash3_x64_128(&bytes, 47).0 as i64;
-        let encoding = m.encoding;
-        let mut first8: u64 = 0;
-        let mut second8: u64 = 0;
-        for (i, b) in bytes.iter().take(8).enumerate() {
-            first8 |= (*b as u64) << (8 * i);
-        }
-        if bytes.len() > 8 {
-            for j in 0..usize::min(8, bytes.len() - 8) {
-                second8 |= (bytes[8 + j] as u64) << (8 * j);
-            }
+    #[allow(clippy::arc_with_non_send_sync)]
+    pub fn get_or_create_meta_string_bytes(

Review Comment:
   could we return `Result<&MetaStringBytes>, Error>` instead? Using `RefCell` is not idiomatic in rust, we should use it sparely



-- 
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: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org