mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
Avoid unnecessary clone()
This commit is contained in:
parent
2f10273d14
commit
c3cdc407ec
@ -317,11 +317,15 @@ fn deladd_obkv_cbo_roaring_bitmaps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Truncates a string to the biggest valid LMDB key size.
|
/// Truncates a string to the biggest valid LMDB key size.
|
||||||
fn truncate_string(s: String) -> String {
|
fn truncate_str(s: &str) -> &str {
|
||||||
s.char_indices()
|
let index = s
|
||||||
.take_while(|(idx, _)| idx + 4 < MAX_FACET_VALUE_LENGTH)
|
.char_indices()
|
||||||
.map(|(_, c)| c)
|
.map(|(idx, _)| idx)
|
||||||
.collect()
|
.chain(std::iter::once(s.len()))
|
||||||
|
.take_while(|idx| idx <= &MAX_FACET_VALUE_LENGTH)
|
||||||
|
.last();
|
||||||
|
|
||||||
|
&s[..index.unwrap_or(0)]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the diff between both Del and Add numbers and
|
/// Computes the diff between both Del and Add numbers and
|
||||||
@ -466,7 +470,7 @@ where
|
|||||||
obkv.insert(DelAdd::Addition, add)?;
|
obkv.insert(DelAdd::Addition, add)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let truncated = truncate_string(normalized.clone());
|
let truncated = truncate_str(normalized);
|
||||||
key_buffer.extend_from_slice(truncated.as_bytes());
|
key_buffer.extend_from_slice(truncated.as_bytes());
|
||||||
|
|
||||||
let bytes = obkv.into_inner()?;
|
let bytes = obkv.into_inner()?;
|
||||||
@ -490,7 +494,7 @@ where
|
|||||||
(DelAdd::Addition, normalized, original)
|
(DelAdd::Addition, normalized, original)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let truncated = truncate_string(normalized.clone());
|
let truncated = truncate_str(normalized);
|
||||||
key_buffer.extend_from_slice(truncated.as_bytes());
|
key_buffer.extend_from_slice(truncated.as_bytes());
|
||||||
|
|
||||||
let mut obkv = KvWriterDelAdd::memory();
|
let mut obkv = KvWriterDelAdd::memory();
|
||||||
|
Loading…
Reference in New Issue
Block a user