Shreemanarjun / Shreemanarjun/nitro_server

perf: Router::match should return a pointer, not copy RouteEntry

Open Beginner friendly
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Problem

Router::match copies the matched RouteEntry (method, pattern strings, flags) into the MatchResult on every request. On the hot path this is an avoidable allocation/copy per request.

Proposal

Return a const RouteEntry* into the trie node instead of copying, since the router outlives the match on the request path (routes only change under the config lock). Keep the params vector as-is. Small, self-contained; covered by test/cpp/router_test.cpp.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Router::match and the MatchResult/RouteEntry definitions, then read test/cpp/router_test.cpp to understand the existing expectations. Confirm the matched entry is referenced rather than copied while the params vector remains unchanged, and run the router tests to verify the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.