Commit 28f3072658bbb43b7ba72f8081491122e0827fb3
1 parent
0cf37d9c
[~] refactor and improve the speed of the separate_uri_from_query_string() function
Showing
1 changed file
with
26 additions
and
16 deletions
Show diff stats
web/multihost_http_server.anubis
| @@ -1571,20 +1571,30 @@ define Result(Error,String) | @@ -1571,20 +1571,30 @@ define Result(Error,String) | ||
| 1571 | 1571 | ||
| 1572 | 1572 | ||
| 1573 | define (String,String) | 1573 | define (String,String) |
| 1574 | - separate_uri_from_query_string | ||
| 1575 | - ( | ||
| 1576 | - String uri_and_query_string, | ||
| 1577 | - Int n | ||
| 1578 | - ) = | ||
| 1579 | - if nth(n,uri_and_query_string) is | ||
| 1580 | - { | ||
| 1581 | - failure then (uri_and_query_string,""), | ||
| 1582 | - success(c) then | ||
| 1583 | - if c = '?' | ||
| 1584 | - then (substr(uri_and_query_string,0,n), | ||
| 1585 | - substr(uri_and_query_string,n+1,length(uri_and_query_string)-(n+1))) | ||
| 1586 | - else separate_uri_from_query_string(uri_and_query_string,n+1) | ||
| 1587 | - }. | 1574 | + separate_uri_from_query_string |
| 1575 | + ( | ||
| 1576 | + String uri_and_query_string, | ||
| 1577 | + ) = | ||
| 1578 | + if find_string(uri_and_query_string, "?", 0) is | ||
| 1579 | + { | ||
| 1580 | + failure then (uri_and_query_string,""), | ||
| 1581 | + success(pos) then (substr(uri_and_query_string, 0, pos), | ||
| 1582 | + substr(uri_and_query_string, pos+1, length(uri_and_query_string)-(pos+1))) | ||
| 1583 | + } | ||
| 1584 | +. | ||
| 1585 | + | ||
| 1586 | +// if nth(n, uri_and_query_string) is | ||
| 1587 | +// { | ||
| 1588 | +// failure then (uri_and_query_string,""), | ||
| 1589 | +// success(c) then | ||
| 1590 | +// if c = '?' | ||
| 1591 | +// then (substr(uri_and_query_string,0,n), | ||
| 1592 | +// substr(uri_and_query_string,n+1,length(uri_and_query_string)-(n+1))) | ||
| 1593 | +// else separate_uri_from_query_string(uri_and_query_string,n+1) | ||
| 1594 | +// } | ||
| 1595 | +//. | ||
| 1596 | + | ||
| 1597 | + | ||
| 1588 | 1598 | ||
| 1589 | 1599 | ||
| 1590 | 1600 | ||
| @@ -1742,8 +1752,8 @@ public define Result(Error, HTTP_Request_Line) | @@ -1742,8 +1752,8 @@ public define Result(Error, HTTP_Request_Line) | ||
| 1742 | error(msg) then error(msg), | 1752 | error(msg) then error(msg), |
| 1743 | ok(_) then | 1753 | ok(_) then |
| 1744 | 1754 | ||
| 1745 | - if separate_uri_from_query_string(uri_and_query_string,0) is | ||
| 1746 | - (uri,query_string) then | 1755 | + if separate_uri_from_query_string(uri_and_query_string) is |
| 1756 | + (uri, query_string) then | ||
| 1747 | if identify_get_or_post(method) is | 1757 | if identify_get_or_post(method) is |
| 1748 | { | 1758 | { |
| 1749 | error(msg) then error(msg), | 1759 | error(msg) then error(msg), |