Commit eb54a33
cat-file: skip expanding default format
When format is passed into --batch, --batch-check, --batch-command,
the format gets expanded. When nothing is passed in, the default format
is set and the expand_format() gets called.
We can save on these cycles by hardcoding how to print the
information when nothing is passed as the format, or when the default
format is passed. There is no need for the fully expanded format with
the default. Since batch_object_write() happens on every object provided
in batch mode, we get a nice performance improvement.
git rev-list --all > /tmp/all-obj.txt
git cat-file --batch-check </tmp/all-obj.txt
with HEAD^:
Time (mean ± σ): 57.6 ms ± 1.7 ms [User: 51.5 ms, System: 6.2 ms]
Range (min … max): 54.6 ms … 64.7 ms 50 runs
with HEAD:
Time (mean ± σ): 49.8 ms ± 1.7 ms [User: 42.6 ms, System: 7.3 ms]
Range (min … max): 46.9 ms … 55.9 ms 56 runs
If nothing is provided as a format argument, or if the default format is
passed, skip expanding of the format and print the object info with a
default format.
See https://lore.kernel.org/git/[email protected]/
Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Signed-off-by: John Cai <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent c216290 commit eb54a33
2 files changed
+35
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
354 | 361 | | |
355 | 362 | | |
356 | 363 | | |
| |||
382 | 389 | | |
383 | 390 | | |
384 | 391 | | |
385 | | - | |
386 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
387 | 400 | | |
388 | 401 | | |
389 | 402 | | |
| |||
508 | 521 | | |
509 | 522 | | |
510 | 523 | | |
| 524 | + | |
| 525 | + | |
511 | 526 | | |
512 | 527 | | |
513 | 528 | | |
| |||
516 | 531 | | |
517 | 532 | | |
518 | 533 | | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | 534 | | |
523 | 535 | | |
524 | 536 | | |
525 | 537 | | |
526 | 538 | | |
527 | 539 | | |
528 | 540 | | |
529 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
530 | 545 | | |
531 | 546 | | |
532 | 547 | | |
533 | 548 | | |
534 | 549 | | |
| 550 | + | |
| 551 | + | |
535 | 552 | | |
536 | 553 | | |
537 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments