Commit 0028139
committed
Add a small speed up to
Avoid a mandatory allocation in `PathDecanonicalized` by taking an output
`std::string*` to append to. Improve its performance by swapping
`strchr` with `std::string::find`, which can take advantage of knowing
the length of the string.
We can also return as soon as we run out of forwardslashes that need to be
turned into backslashes, instead of iterating through all
forwardslashes. If backslashes are the common path separator in ninja
build files on Windows, it may be worthwhile canonicalizing paths into
backslashes-only, which would now allow us to skip the loop entirely in
`PathDecanonicalized` in the case of paths with no forwardslashes.
Rename this function to `AppendPathDecanonicalized` to reflect its new
functionality.
Running `manifest_parser_perftest.exe` on Windows gives initial timings
of:
min 549ms max 613ms avg 573.1ms
and timings after this change of:
min 534ms max 597ms avg 559.9ms
which is a 2-3% improvement.PathDecanonicalized
1 parent cc60300 commit 0028139
4 files changed
+71
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| 487 | + | |
487 | 488 | | |
488 | 489 | | |
489 | 490 | | |
490 | | - | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
492 | 494 | | |
493 | | - | |
| 495 | + | |
494 | 496 | | |
495 | | - | |
| 497 | + | |
496 | 498 | | |
497 | 499 | | |
498 | | - | |
| 500 | + | |
499 | 501 | | |
500 | 502 | | |
501 | 503 | | |
| |||
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | | - | |
584 | | - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
585 | 591 | | |
586 | | - | |
587 | | - | |
588 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
589 | 603 | | |
590 | | - | |
591 | | - | |
| 604 | + | |
| 605 | + | |
592 | 606 | | |
593 | 607 | | |
594 | | - | |
595 | 608 | | |
596 | 609 | | |
597 | 610 | | |
| |||
788 | 801 | | |
789 | 802 | | |
790 | 803 | | |
791 | | - | |
792 | | - | |
| 804 | + | |
| 805 | + | |
793 | 806 | | |
| 807 | + | |
794 | 808 | | |
795 | | - | |
796 | 809 | | |
797 | | - | |
| 810 | + | |
| 811 | + | |
798 | 812 | | |
799 | | - | |
| 813 | + | |
800 | 814 | | |
801 | | - | |
| 815 | + | |
802 | 816 | | |
803 | | - | |
804 | 817 | | |
805 | | - | |
| 818 | + | |
806 | 819 | | |
| 820 | + | |
807 | 821 | | |
808 | 822 | | |
809 | 823 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
626 | 651 | | |
627 | 652 | | |
628 | 653 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
355 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| |||
0 commit comments