Skip to content

Commit d0367c6

Browse files
abnegateclaude
andcommitted
perf(database): inline silent() in getDocument collection lookup
Same change as the other silent() inlines: getDocument calls silent(fn () => \$this->getCollection(\$collection)) on every read, which costs a Closure allocation per call. Replace with a direct flag toggle. This finally clears the per-find Closure tax — complex_query_nested drops from ~2.0s to ~1.3s (a 34% improvement) on the focus bench once silent and authorization toggles are both inlined. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent af6ee56 commit d0367c6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Database/Traits/Documents.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,13 @@ public function getDocument(string $collection, string $id, array $queries = [],
170170
return new Document();
171171
}
172172

173-
$collection = $this->silent(fn () => $this->getCollection($collection));
173+
$previousSilenced = $this->eventsSilenced;
174+
$this->eventsSilenced = true;
175+
try {
176+
$collection = $this->getCollection($collection);
177+
} finally {
178+
$this->eventsSilenced = $previousSilenced;
179+
}
174180

175181
if ($collection->isEmpty()) {
176182
throw new NotFoundException('Collection not found');

0 commit comments

Comments
 (0)