Commit 23dd6f8
sparse-index: use strbuf in path_found()
The path_found() method previously reused strings from the cache entries
the calling methods were using. This prevents string manipulation in
place and causes some odd reallocation before the final lstat() call in
the method.
Refactor the method to use strbufs and copy the path into the strbuf,
but also only the parent directory and not the whole path. This looks
like extra copying when assigning the path to the strbuf, but we save an
allocation by dropping the 'tmp' string, and we are "reusing" the copy
from 'tmp' to put the data in the strbuf.
Signed-off-by: Derrick Stolee <[email protected]>
Reviewed-by: Elijah Newren <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent b746a85 commit 23dd6f8
1 file changed
+9
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
444 | | - | |
| 443 | + | |
445 | 444 | | |
446 | 445 | | |
447 | 446 | | |
448 | 447 | | |
| 448 | + | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
462 | 461 | | |
463 | 462 | | |
464 | 463 | | |
465 | 464 | | |
466 | 465 | | |
467 | | - | |
| 466 | + | |
468 | 467 | | |
469 | 468 | | |
470 | 469 | | |
| |||
486 | 485 | | |
487 | 486 | | |
488 | 487 | | |
489 | | - | |
490 | | - | |
| 488 | + | |
| 489 | + | |
491 | 490 | | |
492 | 491 | | |
493 | 492 | | |
494 | | - | |
495 | | - | |
| 493 | + | |
| 494 | + | |
496 | 495 | | |
497 | | - | |
498 | | - | |
499 | | - | |
| 496 | + | |
500 | 497 | | |
501 | 498 | | |
502 | 499 | | |
| |||
0 commit comments