core icon indicating copy to clipboard operation
core copied to clipboard

Routing Optimization

Open bproctor opened this issue 15 years ago • 1 comments

The routing code currently loops through all the entries to find a URI match. To speed this up for when the routing array starts to get large, there could be an initial check to see if the URI is a key in the array before looping through to find a regex match. I think this would greatly increase the execution time it takes when the routes array starts to get large.

For example:

<?php
if (isset ($routes[$uri])
{
    // found a match!
}
else
{
    // loop through entire array
}

(not sure how to label this as a "Feature" request...)

bproctor avatar Sep 25 '11 14:09 bproctor

Routes are indexed by their name, not the expected path, to allow reverse routing (these are the same for non-named routes, but you can't ever be sure unless you check the route). Thus this is not possible, another solution would be to do a separate index for non-regex routes but I think that just creates a mess that might even slow-down or be too little a performance boost to be worthwhile.

jschreuder avatar Sep 30 '11 09:09 jschreuder