@@ -721,7 +721,6 @@ namespace crow // NOTE: Already documented in "crow/app.h"
721721
722722 constexpr size_t RULE_SPECIAL_REDIRECT_SLASH = 1 ;
723723
724-
725724 // / A search tree.
726725 class Trie
727726 {
@@ -1317,7 +1316,9 @@ namespace crow // NOTE: Already documented in "crow/app.h"
13171316
13181317 ruleObject->foreach_method ([&](int method) {
13191318 per_methods_[method].rules .emplace_back (ruleObject);
1320- per_methods_[method].trie .add (rule, per_methods_[method].rules .size () - 1 , BP_index != INVALID_BP_ID ? blueprints[BP_index]->prefix ().length () : 0 , BP_index);
1319+ per_methods_[method].trie .add (rule, per_methods_[method].rules .size () - 1 ,
1320+ BP_index != INVALID_BP_ID ? blueprints[BP_index]->prefix ().length () : 0 ,
1321+ BP_index);
13211322
13221323 // directory case:
13231324 // request to '/about' url matches '/about/' rule
@@ -1528,11 +1529,12 @@ namespace crow // NOTE: Already documented in "crow/app.h"
15281529 CatchallRule& get_catch_all (const routing_handle_result& found) {
15291530 std::vector<Blueprint*> bps_found;
15301531 get_found_bp (found.blueprint_indices , blueprints_, bps_found);
1531- for (int i = bps_found.size () - 1 ; i > 0 ; i--)
1532- {
1533- std::vector<size_t > bpi = found.blueprint_indices ;
1534- if (bps_found[i]->catchall_rule ().has_handler ()) {
1535- return bps_found[i]->catchall_rule ();
1532+ if (!bps_found.empty ()) {
1533+ for (size_t i = bps_found.size () - 1 ; i > 0 ; i--)
1534+ {
1535+ if (bps_found[i]->catchall_rule ().has_handler ()) {
1536+ return bps_found[i]->catchall_rule ();
1537+ }
15361538 }
15371539 }
15381540 return catchall_rule_;
@@ -1544,20 +1546,17 @@ namespace crow // NOTE: Already documented in "crow/app.h"
15441546
15451547 std::vector<Blueprint*> bps_found;
15461548 get_found_bp (found.blueprint_indices , blueprints_, bps_found);
1547- for (int i = bps_found.size () - 1 ; i > 0 ; i--)
1548- {
1549- std::vector<size_t > bpi = found.blueprint_indices ;
1550- if (bps_found[i]->catchall_rule ().has_handler ())
1551- {
1549+ if (!bps_found.empty ()) {
1550+ for (size_t i = bps_found.size () - 1 ; i > 0 ; i--) {
1551+ if (bps_found[i]->catchall_rule ().has_handler ()) {
15521552#ifdef CROW_ENABLE_DEBUG
1553- return std::string (" Redirected to Blueprint \" " + bps_found[i]->prefix () + " \" Catchall rule" );
1553+ return std::string (" Redirected to Blueprint \" " + bps_found[i]->prefix () + " \" Catchall rule" );
15541554#else
1555- return EMPTY;
1555+ return EMPTY;
15561556#endif
1557+ }
15571558 }
1558- }
1559- if (catchall_rule_.has_handler ())
1560- {
1559+ } else if (catchall_rule_.has_handler ()) {
15611560#ifdef CROW_ENABLE_DEBUG
15621561 return std::string (" Redirected to global Catchall rule" );
15631562#else
0 commit comments