Skip to content

Conversation

@boulabiar
Copy link

• routing: use size_t for rule/blueprint indices; remove narrowing;

  • Replace uint16_t-based indices with size_t to avoid narrowing warnings.
  • include/crow/common.h
    • routing_handle_result
      • rule_index → size_t (was uint16_t)
      • blueprint_indices → std::vector<size_t> (was std::vector<uint16_t>)
      • Constructors updated to take size_t and std::vector<size_t>
  • include/crow/routing.h
    • Constants
      • INVALID_BP_ID → constexpr size_t INVALID_BP_ID{SIZE_MAX} (was uint16_t)
      • RULE_SPECIAL_REDIRECT_SLASH → constexpr size_t = 1 (was const int)
    • Trie::Node
      • rule_index → size_t (was uint16_t)
      • blueprint_index → size_t (was uint16_t)
    • Trie::find
      • Signature: pos → size_t; blueprints → std::vector<size_t>*
      • Locals: MT → std::vector<size_t>, found → size_t, found_BP → std::vector<size_t>
    • Trie::add
      • Signature: rule_index → size_t; blueprint_index → size_t
    • Router wiring
      • internal_add_rule_object overload BP_index → const size_t&
      • get_found_bp signature → std::vector<size_t>, index → size_t
      • bpi locals → std::vector<size_t>
      • Default routing_handle_result construction uses std::vector<size_t>()
      • rule_index locals → size_t

…g (routing_handle_result and Trie/Router) to eliminate narrowing warnings
@boulabiar
Copy link
Author

A stress test creating thousands of routes may be useful to see whether this reduced performance due to cache misses from the use of a bigger strcuture (size_t == 2x uint16_t)

@gittiver
Copy link
Member

Well, that is done on startup normally, so it should have no influence when all rules are setup and requests are handled.
But, well, testing is always a good idea.

@gittiver gittiver closed this Nov 21, 2025
@gittiver gittiver reopened this Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants