Commit b09f5a6
committed
refactor: simplify ParseClauseSegment verb-extraction loop
Drop the `quotedFirstVerb` flag and gate the walk solely on `firstVerb is
not null` — the QuotedString branch no longer needs a sentinel because
it falls through with `firstVerb == null` and the loop short-circuits.
Cache the inner `HashSet<string>` from `FlagsWithValue` once into
`flagsForVerb` instead of re-hashing `firstVerb` on every flag-token
iteration. Inline the `=`-position scan via a single `IndexOf('=')` call
so the `--flag=value` short-circuit doesn't traverse the flag string
twice; this lets us delete the now-unused `StripEqualsValue` and
`HasInlineEqualsValue` helpers.
Trim the 20-line block comment at the top of `ParseClauseSegment` to
just the load-bearing invariants (FileVerb carveout + ordering with
flag-with-value consumption). Drop mid-loop comments that narrate the
control flow. Add a 4-element capacity hint to `verbTokens` to avoid
the first realloc on the typical case.
In `BashVerbs.cs`, revert the `FileVerbs` remarks paragraph that leaked
parser usage details and rewrite the `IsVerbLikeToken` doc to capture
the WHY of the strict allow-list (vs. negation-of-LooksLikePath)
without re-listing all the rejection categories.
All 394 tests still pass; no behavior change.1 parent 6166244 commit b09f5a6
2 files changed
Lines changed: 52 additions & 106 deletions
Lines changed: 41 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
792 | 778 | | |
793 | | - | |
| 779 | + | |
794 | 780 | | |
795 | 781 | | |
796 | 782 | | |
797 | 783 | | |
798 | | - | |
799 | 784 | | |
800 | 785 | | |
801 | 786 | | |
| 787 | + | |
| 788 | + | |
802 | 789 | | |
803 | 790 | | |
804 | 791 | | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
812 | 796 | | |
813 | 797 | | |
814 | 798 | | |
| 799 | + | |
815 | 800 | | |
816 | | - | |
817 | 801 | | |
818 | 802 | | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
| 803 | + | |
824 | 804 | | |
825 | 805 | | |
826 | 806 | | |
| |||
832 | 812 | | |
833 | 813 | | |
834 | 814 | | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
| 815 | + | |
844 | 816 | | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
| 817 | + | |
| 818 | + | |
851 | 819 | | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
856 | 825 | | |
857 | 826 | | |
858 | | - | |
859 | | - | |
860 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
861 | 833 | | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
868 | 845 | | |
869 | 846 | | |
870 | | - | |
| 847 | + | |
871 | 848 | | |
872 | 849 | | |
873 | 850 | | |
| |||
958 | 935 | | |
959 | 936 | | |
960 | 937 | | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | 938 | | |
976 | 939 | | |
977 | 940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | 46 | | |
48 | 47 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 48 | | |
59 | 49 | | |
60 | 50 | | |
| |||
130 | 120 | | |
131 | 121 | | |
132 | 122 | | |
133 | | - | |
134 | | - | |
| 123 | + | |
| 124 | + | |
135 | 125 | | |
136 | 126 | | |
137 | 127 | | |
138 | 128 | | |
139 | 129 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
156 | 139 | | |
157 | 140 | | |
158 | 141 | | |
| |||
0 commit comments