﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35518	Avoid regex search for simple route patterns	Jake Howard	Jake Howard	"The `RoutePattern` assumes all routes provided include some form of converter, and so needs to change it into a regex for matching. However, if no converters are included in the string, the additional overhead of using a regex vs simpler string operations is unnecessary.

Replacing this with a simpler string comparison results in between a 50 and 75% reduction in match time, which stacks up quickly as an application generally has numerous URLs. This can be done by modifying the `RoutePattern` internally, with no external breakages.

**Before**

{{{#!python
In [2]: endpoint_pattern = RoutePattern(""foo/"", ""name"", is_endpoint=True)

In [3]: pattern = RoutePattern(""foo/"", ""name"", is_endpoint=False)

In [4]: %timeit pattern.match(""foo/"")
441 ns ± 2.68 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [5]: %timeit endpoint_pattern.match(""foo/"")
435 ns ± 0.974 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
}}}

**After**

{{{#!python
In [4]: %timeit pattern.match(""foo/"")
187 ns ± 1.84 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

In [5]: %timeit endpoint_pattern.match(""foo/"")
103 ns ± 0.192 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
}}}

Theoretically, these improvements get better based on the length of the route pattern (although at this scale, not notably).

This optimisation could be done by adding a different kind of pattern (eg `LiteralPattern`), but the added complexity to a project probably isn't necessary, not to mention the migration effort to take advantage of this."	Cleanup/optimization	closed	Core (URLs)	5.2	Normal	fixed		Adam Johnson	Ready for checkin	1	0	0	0	0	0
