Skip to content

Commit 3016ec5

Browse files
committed
reduce routes memory footprint
1 parent c215097 commit 3016ec5

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- `Innmind\Framework\Application::mapRoutes()`
88

9+
### Changed
10+
11+
- Reduced routes memory footprint
12+
913
## 4.0.2 - 2026-04-12
1014

1115
### Fixed

‎src/Application/Async/Http.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function of(OperatingSystem $os): self
7777
$os,
7878
static fn(OperatingSystem $os, Environment $env) => [$os, $env],
7979
static fn() => Builder::new(),
80-
Sequence::lazyStartingWith(),
80+
Sequence::of(),
8181
static fn(Component $component) => $component,
8282
static fn(Component $component) => $component,
8383
$notFound,
@@ -285,7 +285,9 @@ public function run($input): Attempt
285285
{
286286
$map = $this->map;
287287
$container = $this->container;
288-
$routes = $this->routes;
288+
$routes = Sequence::lazyStartingWith($this->routes)->flatMap(
289+
static fn($routes) => $routes,
290+
);
289291
$notFound = $this->notFound;
290292
$mapRoute = $this->mapRoute;
291293
$mapRoutes = $this->mapRoutes;

‎src/Application/Http.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function of(OperatingSystem $os, Environment $env): self
6868
$os,
6969
$env,
7070
static fn() => Builder::new(),
71-
Sequence::lazyStartingWith(),
71+
Sequence::of(),
7272
static fn(Component $component) => $component,
7373
static fn(Component $component) => $component,
7474
$notFound,
@@ -267,8 +267,8 @@ public function run($input): Attempt
267267
$mapRoutes = $this->mapRoutes;
268268
$recover = $this->recover;
269269
$pipe = Pipe::new();
270-
$routes = $this
271-
->routes
270+
$routes = Sequence::lazyStartingWith($this->routes)
271+
->flatMap(static fn($routes) => $routes)
272272
->map(static fn($handle) => $handle($pipe, $container))
273273
->map(static fn($component) => $mapRoute($component, $container));
274274
$router = new Router(

0 commit comments

Comments
 (0)