File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1204,8 +1204,12 @@ impl<'a> ObjectBuilder<'a> {
1204
1204
let field_b_name = metadata_builder. field_name ( field_b_id as usize ) ;
1205
1205
field_a_name. cmp ( field_b_name)
1206
1206
} ) ;
1207
- let max_id = self . fields . iter ( ) . map ( |( i, _) | * i) . max ( ) . unwrap_or ( 0 ) ;
1208
- let id_size = int_size ( max_id as usize ) ;
1207
+
1208
+ // the length of the metadata's field names is a very cheap to compute the upper bound.
1209
+ // it will almost always be a tight upper bound as well -- it would take a pretty
1210
+ // carefully crafted object to use only the early field ids of a large dictionary.
1211
+ let max_id = metadata_builder. field_names . len ( ) ;
1212
+ let id_size = int_size ( max_id) ;
1209
1213
1210
1214
let parent_buffer = self . parent_state . buffer ( ) ;
1211
1215
let current_offset = parent_buffer. offset ( ) ;
You can’t perform that action at this time.
0 commit comments