@@ -98,6 +98,11 @@ export function parseMatches(text: string, args: ParseMatchesArgs): Match[] {
98
98
for ( let stateIdx = context . stateMachines . length - 1 ; stateIdx >= 0 ; stateIdx -- ) {
99
99
const stateMachine = context . stateMachines [ stateIdx ] ;
100
100
101
+ // Performance note: tried turning this switch/case into a lookup
102
+ // table, but resulted in ~350 fewer ops/sec in benchmarks.
103
+ // Switch/case may be more efficient due to potential function
104
+ // inlining by the engine? Either way, run benchmarks if
105
+ // attempting to change again.
101
106
switch ( stateMachine . state ) {
102
107
// Protocol-relative URL states
103
108
case State . ProtocolRelativeSlash1 :
@@ -137,7 +142,7 @@ export function parseMatches(text: string, args: ParseMatchesArgs): Match[] {
137
142
stateIpV4Digit ( context , stateMachine as IpV4UrlStateMachine , char ) ;
138
143
break ;
139
144
case State . IpV4Dot :
140
- stateIPv4Dot ( context , stateMachine as IpV4UrlStateMachine , char ) ;
145
+ stateIpV4Dot ( context , stateMachine as IpV4UrlStateMachine , char ) ;
141
146
break ;
142
147
143
148
case State . PortColon :
@@ -556,7 +561,7 @@ function stateIpV4Digit(
556
561
}
557
562
}
558
563
559
- function stateIPv4Dot (
564
+ function stateIpV4Dot (
560
565
context : ParseMatchesContext ,
561
566
stateMachine : IpV4UrlStateMachine ,
562
567
char : string
0 commit comments