@@ -288,7 +288,9 @@ class UniversalCompactionBuilder {
288
288
// and the index of the file in that level
289
289
290
290
struct InputFileInfo {
291
- InputFileInfo () : f(nullptr ), level(0 ), index(0 ) {}
291
+ InputFileInfo () : InputFileInfo(nullptr , 0 , 0 ) {}
292
+ InputFileInfo (FileMetaData* file_meta, size_t l, size_t i)
293
+ : f(file_meta), level(l), index(i) {}
292
294
293
295
FileMetaData* f;
294
296
size_t level;
@@ -321,22 +323,14 @@ SmallestKeyHeap create_level_heap(Compaction* c, const Comparator* ucmp) {
321
323
SmallestKeyHeap smallest_key_priority_q =
322
324
SmallestKeyHeap (SmallestKeyHeapComparator (ucmp));
323
325
324
- InputFileInfo input_file;
325
-
326
326
for (size_t l = 0 ; l < c->num_input_levels (); l++) {
327
327
if (c->num_input_files (l) != 0 ) {
328
328
if (l == 0 && c->start_level () == 0 ) {
329
329
for (size_t i = 0 ; i < c->num_input_files (0 ); i++) {
330
- input_file.f = c->input (0 , i);
331
- input_file.level = 0 ;
332
- input_file.index = i;
333
- smallest_key_priority_q.push (std::move (input_file));
330
+ smallest_key_priority_q.emplace (c->input (0 , i), 0 , i);
334
331
}
335
332
} else {
336
- input_file.f = c->input (l, 0 );
337
- input_file.level = l;
338
- input_file.index = 0 ;
339
- smallest_key_priority_q.push (std::move (input_file));
333
+ smallest_key_priority_q.emplace (c->input (l, 0 ), l, 0 );
340
334
}
341
335
}
342
336
}
@@ -374,7 +368,7 @@ bool UniversalCompactionBuilder::IsInputFilesNonOverlapping(Compaction* c) {
374
368
auto comparator = icmp_->user_comparator ();
375
369
int first_iter = 1 ;
376
370
377
- InputFileInfo prev, curr, next ;
371
+ InputFileInfo prev, curr;
378
372
379
373
SmallestKeyHeap smallest_key_priority_q =
380
374
create_level_heap (c, icmp_->user_comparator ());
@@ -397,17 +391,10 @@ bool UniversalCompactionBuilder::IsInputFilesNonOverlapping(Compaction* c) {
397
391
prev = curr;
398
392
}
399
393
400
- next.f = nullptr ;
401
-
402
394
if (c->level (curr.level ) != 0 &&
403
395
curr.index < c->num_input_files (curr.level ) - 1 ) {
404
- next.f = c->input (curr.level , curr.index + 1 );
405
- next.level = curr.level ;
406
- next.index = curr.index + 1 ;
407
- }
408
-
409
- if (next.f ) {
410
- smallest_key_priority_q.push (std::move (next));
396
+ smallest_key_priority_q.emplace (c->input (curr.level , curr.index + 1 ),
397
+ curr.level , curr.index + 1 );
411
398
}
412
399
}
413
400
return true ;
0 commit comments