refactor Term

fixes some issues with Term
Remove duplicate calls to truncate or resize
Replace Magic Number 5 with constant
Enforce minimum size of 5 for metadata
Fix broken truncate docs
use constructor instead new + set calls
normalize constructor stack
replace assert on internal behavior fixes #1585
This commit is contained in:
Pascal Seitz
2022-10-11 19:17:31 +08:00
parent 6b7b1cc4fa
commit fcfd76ec55
4 changed files with 95 additions and 90 deletions

View File

@@ -734,9 +734,8 @@ fn generate_literals_for_json_object(
index_record_option: IndexRecordOption,
) -> Result<Vec<LogicalLiteral>, QueryParserError> {
let mut logical_literals = Vec::new();
let mut term = Term::new();
let mut json_term_writer =
JsonTermWriter::from_field_and_json_path(field, json_path, &mut term);
let mut term = Term::with_capacity(100);
let mut json_term_writer = JsonTermWriter::from_json_path(json_path, field, &mut term);
if let Some(term) = convert_to_fast_value_and_get_term(&mut json_term_writer, phrase) {
logical_literals.push(LogicalLiteral::Term(term));
}