Skip to content

Conversation

@n0nag0n
Copy link
Collaborator

@n0nag0n n0nag0n commented Aug 17, 2025

Just was thinking with AI about how to increase the performance out of Flight. The router class can instead search by method instead of everything. It helps shave off about 5% of execution time if your project is large enough. Otherwise it's negligible.

@n0nag0n n0nag0n requested a review from Copilot August 17, 2025 17:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances router performance by implementing method-based route grouping to optimize route lookup times. The optimization creates separate arrays grouped by HTTP method, allowing the router to search only relevant routes instead of iterating through all routes.

  • Introduces a new $routesByMethod array to group routes by HTTP method for faster lookups
  • Modifies the routing algorithm to check method-specific routes first, then fall back to wildcard routes
  • Maintains backward compatibility for existing routing behavior including 405 error handling

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
flight/net/Router.php Implements method-based route grouping with fast-path lookup optimization
tests/EngineTest.php Adds comprehensive tests for route iteration behavior and edge cases
tests/performance/index.php Creates performance testing environment with various route types
tests/performance/performance_tests.sh Provides benchmarking script for measuring routing performance

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@n0nag0n n0nag0n merged commit f0dc1b1 into master Aug 19, 2025
6 checks passed
@n0nag0n n0nag0n deleted the router-performance branch August 19, 2025 12:55
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