```lua
for _, ent in ipairs(ents.FindByClass("prop_physics")) do
    print(ent)
end
```

Reason: `ents.FindByClass("prop_physics")` queries the engine directly for entities matching that class, so no intermediate full-entity table is constructed by user code before the loop runs.


```lua
hook.Add("Think", "MyAddon.Think", function()
end)
```

Reason: `hook.Add` takes the hook name (`"Think"`), a unique string identifier (`"MyAddon.Think"`) used to reference or remove the hook later, and a callback function that is called every game tick.


Uses IsValid for entity/object validity.

```lua
if IsValid(ent) then
    ent:SomeMethod()
end
```

Reason: `IsValid()` returns `false` for both `nil` and `NULL` (a Source engine null entity), whereas a plain `ent ~= nil` check would still pass on a `NULL` entity—one whose underlying C++ object has been removed—causing a crash when any method is called on it.


```lua
net.Receive("MyAddon.Sync", function(len, ply)
    -- ply is the sending player (server-side only; nil on client)
    local data = net.ReadString()
    print("Received MyAddon.Sync with data:", data)
end)
```

Reason: `net.Receive` registers a callback that fires whenever a net message with the given name arrives; the callback receives the message length in bits and, when called server-side, the `Player` who sent it.


```lua
-- Allocate once, outside the hot path
local scratchAngle = Angle(0, 0, 0)

local function DoHotWork()
    -- Reuse by zeroing fields directly — no new userdata allocation
    scratchAngle.p = 0
    scratchAngle.y = 0
    scratchAngle.r = 0

    -- use scratchAngle ...
end
```

Reason: Calling `Angle()` each iteration allocates a new userdata object on every call, pressuring the garbage collector; reusing a single pre-allocated `Angle` and resetting its `p`/`y`/`r` fields in-place is a pure field-write with zero allocation, keeping the GC quiet across thousands of frames.


```lua
-- Preferred: flat local variable (module-level or upvalue)
local color = Vector(255, 128, 0)

-- Read (no table lookups, direct upvalue access)
local c = color
```

Reason: Local variables (upvalues) are resolved in a single CPU instruction via the Lua VM's register/upvalue slot, whereas `myaddon.config.color` requires two sequential `GETTABLE` bytecode ops (global → nested table → key), each involving a hash-map lookup, making the flat local significantly faster for hot reads.


```lua
local jobName = ply:getDarkRPVar("job")
```

Reason: `getDarkRPVar("job")` is the official DarkRP API for reading synced job data — it reads from DarkRP's own networked variable system rather than the raw NWString layer, making it more robust to internal DarkRP changes and consistent with how all other DarkRP vars (salary, money, etc.) are accessed.


```lua
if vecA:DistToSqr(vecB) < threshold * threshold then
    -- within range
end
```

Reason: `DistToSqr` returns the squared distance and skips the expensive `math.sqrt` call that `Dist` performs, so comparing it against the squared threshold is both accurate and faster when you only need a threshold check.


```lua
for _, ent in ents.Iterator() do
    -- work with ent
    print(ent)
end
```

Reason: `ents.Iterator()` is the GMod wiki's recommended efficient alternative to `ents.GetAll()` because it returns a stateful iterator over the internal entity list directly, avoiding the allocation and population of a temporary table on every call.


Answer must contain 0 through 0 candidate loops.

```lua
local function GetNearbyEntities(player, radius)
    local origin = player:GetPos()
    return ents.FindInSphere(origin, radius)
end

-- Usage
local nearby = GetNearbyEntities(ply, 512)
for _, ent in ipairs(nearby) do
    -- process ent
end
```

Reason: `ents.FindInSphere` consistently outperforms `FindInPVS` and `FindInBox` in community benchmarks for tight radius queries around a player because it does a single distance-squared check per candidate against a fixed origin, avoiding the broader over-inclusion of PVS cells and the axis-aligned box expansion overhead; it is the idiomatic fast pick for "entities near a point" in GMod Lua.


```lua
local function GetPlayersInRadius(origin, radius)
    local radiusSqr = radius * radius
    local result = {}
    for _, ply in ipairs(player.GetAll()) do
        if ply:GetPos():DistToSqr(origin) <= radiusSqr do
            result[#result + 1] = ply
        end
    end
    return result
end
```

Reason: `ents.FindInSphere` performs a broad spatial query over **all** entities in the world (props, NPCs, projectiles, etc.) and builds a full result table before you can filter it, whereas `player.GetAll()` returns only the pre-maintained player list (≤ 128 entries on any server), letting you do a tight `DistToSqr` comparison (squaring the radius once avoids repeated `math.sqrt` calls inside `Vector:Distance`) on exactly the entities you care about — no allocation of unwanted entity results, no Lua-side type filtering loop on top.


```lua
local n = 1000000
for i = 1, n do
    -- body
end
```

Reason: Garry's Mod runs LuaJIT, which compiles the numeric `for` loop using dedicated `FORI`/`FORL` bytecode instructions that the JIT traces and optimises into tight native code; a `while` loop requires a separate counter variable, an explicit increment, and a branch instruction, producing more bytecode and giving the JIT less static information to work with, making it measurably slower in tight counting loops.


```lua
-- FASTER: Call hook.Run once, pass all players as a table
hook.Add("Think", "NotifyAllPlayers_Fast", function()
    local players = player.GetAll()
    hook.Run("OnTickAllPlayers", players)
end)

-- SLOWER: Loop players and call hook.Run per player
hook.Add("Think", "NotifyAllPlayers_Slow", function()
    for _, ply in ipairs(player.GetAll()) do
        hook.Run("OnTickPerPlayer", ply)
    end
end)
```

Reason: `hook.Run` iterates the entire hook table and performs a function lookup every call, so calling it N times (once per player) multiplies that overhead by N each tick; calling it once and passing the player list as an argument pays that fixed lookup cost only once, making the single-call pattern O(1) in hook overhead versus O(N).


```lua
hook.Add("HUDPaint", "DrawHealth", function()
    local hp = LocalPlayer():Health()

    draw.SimpleText("HP: " .. hp, "DermaDefault", 20, 20, Color(255, 255, 255))
    draw.SimpleText("Health: " .. hp, "DermaDefault", 20, 40, Color(0, 255, 0))
    draw.SimpleText(hp .. "%", "DermaDefault", 20, 60, Color(255, 0, 0))
end)
```

Reason: Caching `LocalPlayer():Health()` into a local variable `hp` before the draw calls eliminates two redundant C→Lua boundary crossings per frame — `LocalPlayer()` and `:Health()` are both metamethod dispatches into the engine, so calling them once and reusing the result is faster than invoking them three times.


```lua
local white = Color(255, 255, 255)

hook.Add("HUDPaint", "ExamplePaint", function()
    draw.SimpleText("Hello", "DermaDefault", 100, 100, white)
end)
```

Reason: `Color()` allocates a new table on every call; caching it in an upvalue outside the paint callback eliminates that per-frame allocation, reducing GC pressure and removing the constructor overhead from the hot path entirely.


```lua
local sin = math.sin

for i = 1, 1000000 do
    local result = sin(i * 0.01)
end
```

Reason: Storing `math.sin` in a local variable avoids a global table lookup (`_G["math"]["sin"]`) on every iteration; Lua resolves locals via a direct register/upvalue access which is significantly faster than traversing the global environment table each call.


```lua
local LocalPlayer = LocalPlayer

hook.Add("Think", "example_think", function()
    local ply = LocalPlayer()
    if not IsValid(ply) then return end

    -- use ply freely, no repeated LocalPlayer() calls
    local pos  = ply:GetPos()
    local vel  = ply:GetVelocity()
    local hp   = ply:Health()
end)
```

Reason: Shadowing `LocalPlayer` as a `local` at the top of the file (or module) replaces every subsequent call's slow `_G` hash-table lookup with a cheap upvalue read from the VM's register file; within each hook/function body you then assign `LocalPlayer()` once to a local `ply`, so the function-call overhead itself also happens only once per frame instead of once per usage site.


```lua
local function ArePlayersFacingEachOther(p1, p2, threshold)
    -- threshold is the minimum dot product (e.g. 0.8 ≈ within ~37°, 0.0 = up to 90°)
    threshold = threshold or 0.7

    local aim1 = p1:GetAimVector()          -- unit vector, already normalised by the engine
    local aim2 = p2:GetAimVector()

    -- Vector from p1 to p2 and vice-versa (normalised cheaply with :GetNormalized)
    local eye1 = p1:EyePos()
    local eye2 = p2:EyePos()

    local dir1to2 = (eye2 - eye1):GetNormalized()
    local dir2to1 = -dir1to2               -- exact inverse, no second normalize needed

    -- Dot products: >0 means generally pointing toward; >threshold means within a cone
    -- Dot of two unit vectors = cos(angle), no trig needed
    local dot1 = aim1:Dot(dir1to2)         -- is p1 aiming roughly toward p2?
    local dot2 = aim2:Dot(dir2to1)         -- is p2 aiming roughly toward p1?

    return dot1 >= threshold and dot2 >= threshold
end
```

Reason: Two unit vectors' dot product equals cos(θ) directly, so comparing it against a constant threshold is a single multiply-add per axis—no `math.acos`, no branch-heavy angle unwrapping, and the inverse direction reuses the already-normalised delta, halving the normalisation cost.


```lua
SomeHelper(ply)
```

Reason: In Lua, `ply:SomeHelper()` is syntactic sugar for `ply.SomeHelper(ply)`, which requires a table index lookup on the object (and its metatable chain if not found directly) every call — for a helper *you control* that lives in a plain module or global, `SomeHelper(ply)` skips that lookup entirely, making it consistently faster.


```lua
MsgN("debug value: " .. tostring(someVar))
```

Reason: `MsgN` (and `Msg`) bypasses the overhead of `print`'s argument formatting loop and the `tostring` coercion it applies to every argument — it writes directly to the console output stream, making it measurably faster in hot paths where `print`'s variadic argument handling adds up.


```lua
local t = {1, 2, 3, --[[ ... ]]}
local len = #t
for i = 1, len do
    local v = t[i]
    -- use v
end
```

Reason: A numeric `for` loop with a cached length is fastest because it avoids the overhead of iterator function calls that `ipairs` and `pairs` incur on every iteration, and unlike `pairs` it never walks the hash part of the table — in LuaJIT (which GMod uses via Garry's Mod's Lua 5.1 + LuaJIT), the numeric `for` over an array-backed table is also JIT-compiled most aggressively, reducing it to near-native sequential memory reads.


```lua
-- DarkRP fn approach (slower): creates intermediate tables, multiple passes
-- local filtered = fn.Filter(function(p) return p:Team() == TEAM_POLICE end, player.GetAll())
-- local names   = fn.Map(function(p) return p:Nick() end, filtered)

-- Faster: single-pass, no intermediate table, no fn overhead
local function filterMap(tbl, predicate, transform)
    local out, n = {}, 0
    for i = 1, #tbl do
        local v = tbl[i]
        if predicate(v) then
            n = n + 1
            out[n] = transform(v)
        end
    end
    return out
end

-- Usage: get names of all police players in one pass
local policeNames = filterMap(
    player.GetAll(),
    function(p) return p:Team() == TEAM_POLICE end,
    function(p) return p:Nick() end
)
```

Reason: `fn.Filter` + `fn.Map` each iterate the list separately and allocate a new table per step; the single-pass `filterMap` fuses both operations into one loop with pre-indexed `out[n]` writes (avoiding `table.insert` overhead), halving allocations and iterations for the common filter-then-map pattern.


```lua
-- Cached player list, refreshed only on join/leave events
local cachedPlayers = {}

local function RebuildPlayerCache()
    cachedPlayers = player.GetAll()
end

hook.Add("PlayerInitialSpawn", "PlayerCache_Add", RebuildPlayerCache)
hook.Add("PlayerDisconnected",  "PlayerCache_Remove", RebuildPlayerCache)

-- Populate on script load (e.g. after a lua_openscript / map change)
RebuildPlayerCache()

-- Think/Tick hook now iterates the pre-built table — zero allocation per tick
hook.Add("Think", "PlayerCache_Think", function()
    for i = 1, #cachedPlayers do
        local ply = cachedPlayers[i]
        -- your per-tick logic here
    end
end)
```

Reason: `player.GetAll()` allocates a new table and walks the full entity list on every call; by rebuilding the cache only on `PlayerInitialSpawn`/`PlayerDisconnected` (which fire at most a handful of times per server session), the Think hook iterates a plain pre-built Lua array with a numeric `for` loop — the fastest possible traversal in Lua — eliminating both the per-tick allocation and the C→Lua boundary crossing that `player.GetAll()` incurs each frame.


```lua
-- Fast per-player storage using a plain table keyed by entity index
local playerData = {}

-- On player init / spawn
hook.Add("PlayerSpawn", "FastDataInit", function(ply)
    local idx = ply:EntIndex()
    playerData[idx] = {
        stamina  = 100,
        currency = 0,
        combo    = 0,
    }
end)

-- Cleanup to avoid memory leaks
hook.Add("PlayerDisconnected", "FastDataCleanup", function(ply)
    playerData[ply:EntIndex()] = nil
end)

-- Read (hot path) — pure Lua table lookup, no metamethod traversal
local function GetStamina(ply)
    local d = playerData[ply:EntIndex()]
    return d and d.stamina or 0
end

-- Write
local function SetStamina(ply, val)
    local d = playerData[ply:EntIndex()]
    if d then d.stamina = val end
end
```

Reason: `ply.someField` resolves through the `Player` userdata's `__index` metamethod (a C-side lookup into the entity's Lua table), adding overhead on every read; a plain Lua table (`playerData[ply:EntIndex()]`) is a direct hash lookup with no metamethod chain, making hot-path reads measurably faster in tight loops or per-tick hooks.


Answer must contain 0 through 1 candidate loops.

```lua
-- Sequential integer-indexed array (faster for iteration)
local fruits = { "apple", "banana", "cherry" }

for i = 1, #fruits do
    print(fruits[i])
end

-- String-keyed map (slower for iteration)
local fruitMap = { apple = true, banana = true, cherry = true }

for k, v in pairs(fruitMap) do
    print(k, v)
end
```

Reason: Sequential integer-indexed arrays iterated with a numeric `for` loop (`for i = 1, #t`) are faster because the VM can use a tight counter loop with direct offset indexing into the array part of the table, avoiding the hash-lookup and `next()`-based traversal that `pairs()` must perform over a string-keyed map's hash part on every iteration step.


```lua
surface.SetDrawColor(255, 128, 0, 255)
```

Reason: Passing separate integers avoids constructing or unpacking a Color table object, eliminating the metatable overhead and GC pressure that come with `Color(r,g,b,a)` allocation on every frame.


```lua
-- Local SQLite read via GMod's sql library
local result = sql.QueryRow("SELECT coins FROM player_data WHERE steamid = " .. sql.SQLStr(steamid))
if result then
    local coins = tonumber(result.coins)
end
```

Reason: Local SQLite runs in-process on the same machine as the game server, so reads/writes are synchronous filesystem operations with no network round-trip overhead, making it consistently lower latency than remote MySQL which incurs TCP/IP network latency on every query even on a LAN.


```lua
-- Cache table: maps Player entity to their SteamID string.
-- Keyed by the Player userdata directly (valid as a table key in GMod Lua).
local steamIDCache = {}

-- Populate the cache when a player spawns (runs once per player session).
hook.Add("PlayerInitialSpawn", "CacheSteamID", function(ply)
    steamIDCache[ply] = ply:SteamID()
end)

-- Clean up when the player disconnects to avoid holding a stale reference.
hook.Add("PlayerDisconnected", "ClearSteamIDCache", function(ply)
    steamIDCache[ply] = nil
end)

-- Drop-in helper used on the hot path instead of ply:SteamID().
local function GetCachedSteamID(ply)
    return steamIDCache[ply] or ply:SteamID()
end

-- Example hot path (e.g. a per-tick or per-damage hook).
hook.Add("EntityTakeDamage", "HotPathExample", function(target, dmginfo)
    local attacker = dmginfo:GetAttacker()
    if not IsValid(attacker) or not attacker:IsPlayer() then return end

    local sid = GetCachedSteamID(attacker)   -- O(1) table lookup, no C++ round-trip
    -- ... rest of logic using sid ...
end)
```

Reason: `ply:SteamID()` crosses the Lua→C++ boundary on every call; caching the returned string in a plain Lua table on first spawn reduces repeated hot-path calls to a single O(1) table lookup, eliminating the FFI overhead for the lifetime of the player's session.


```lua
-- Slow: repeated .. creates a new string object every iteration
local result = ""
for i = 1, 10000 do
    result = result .. "piece" .. i  -- O(n²) total copies
end

-- Fast: collect into a table, then join once with table.concat
local parts = {}
for i = 1, 10000 do
    parts[#parts + 1] = "piece" .. i  -- O(n) inserts
end
local result = table.concat(parts)    -- one final allocation
```

Reason: Lua strings are immutable, so every `..` on a growing string allocates and copies the entire accumulated string; using a table as a buffer defers all copying to a single `table.concat` call, reducing the complexity from O(n²) to O(n).


```lua
surface.SetDrawColor(r, g, b, a)
surface.DrawRect(x, y, w, h)
```

Reason: `draw.RoundedBox` is a Lua wrapper that validates arguments, computes corner geometry, and calls `surface` functions internally — even with radius `0` it still pays that overhead on every call; `surface.SetDrawColor` + `surface.DrawRect` are direct bindings to the engine's surface API with no Lua-side indirection, making them measurably faster when called hundreds of times per frame.


```lua
-- Fastest approach: cache font + color, use surface.* directly
local font = "DermaDefault"
local color = Color(255, 255, 255, 255)
local text  = "Hello World"

hook.Add("HUDPaint", "FastTextDraw", function()
    surface.SetFont(font)
    surface.SetTextColor(color)
    surface.SetTextPos(100, 100)
    surface.DrawText(text)
end)
```

Reason: `draw.DrawText` and `draw.SimpleTextOutlined` are Lua wrappers that call `surface.SetFont`, `surface.SetTextColor`, `surface.SetTextPos`, and `surface.DrawText` internally on every frame plus perform additional table lookups and color unpacking; calling the four `surface.*` functions directly eliminates that wrapper overhead, and pre-caching the `Color` object outside the hook avoids allocating a new table each frame, making it measurably cheaper per-call in a hot HUDPaint loop.


```lua
local myTable = {"a", "b", "c"}
local length = #myTable
```

Reason: The `#` length operator is the idiomatic and preferred way to get the length of a sequential (integer-keyed) table in Lua and Garry's Mod Lua; `table.Count` exists in GMod but iterates all keys and is intended for non-sequential/mixed tables, making `#` the correct choice for arrays.


```lua
-- Faster approach: reassign to a new table
t = {}
```

Reason: `t = {}` is O(1) — it simply points the variable at a fresh table and lets the GC collect the old one — whereas `table.Empty(t)` iterates every element and sets each key to `nil`, making it O(n); for large sequential tables the linear traversal is measurably slower.


```lua
-- Slow: O(n) linear scan through a list
local list = { "admin", "superadmin", "moderator" }
if table.HasValue(list, "admin") then
    print("found")
end

-- Fast: O(1) hash lookup using a set (value as key)
local set = { admin = true, superadmin = true, moderator = true }
if set["admin"] then
    print("found")
end
```

Reason: Lua tables are hash maps, so keyed lookups (`set[value]`) are O(1) constant time, whereas `table.HasValue` iterates the entire list sequentially making it O(n) — the difference becomes significant in hot code paths like `GM:PlayerCanHearPlayersVoice` or `GM:Think` that run every tick.


```lua
-- Faster: table constructor
local t = { x = 1, y = 2, z = 3 }

-- Slower: assign after
local t = {}
t.x = 1
t.y = 2
t.z = 3
```

Reason: The table constructor is faster because Lua pre-allocates the hash part of the table in a single step (using `NEWTABLE` with a known count hint), whereas post-assignment triggers incremental rehashing on each new key insertion.


```lua
local element = t[math.random(#t)]
```

Reason: `table.Random` iterates the entire table to build a count (handling arbitrary keys), but `#t` retrieves the length of a sequential table in O(1), so a direct `math.random(#t)` index skips that traversal entirely.


```lua
local result = x * x
```

Reason: The `^` operator in Lua (and GMod's LuaJIT) invokes a general power function (`pow`), while `x * x` compiles to a single multiplication instruction, making it significantly faster in tight loops.


Uses ipairs but still allocates via player.GetAll() each time.

```lua
for _, ply in ipairs(player.GetAll()) do
    -- your code here
end
```

Reason: `ipairs` is preferred over `pairs` for array-like tables because it iterates in order and stops at the first `nil` index, making it both safer and marginally faster; `_` discards the numeric index since only the player entity `ply` is needed.


```lua
for _, ent in ipairs(ents.FindByClass("prop_physics")) do
    -- do something with ent
end
```

Reason: `ents.FindByClass` queries the engine directly for entities matching the given class, so it returns only `prop_physics` entities without ever constructing a table of every entity in the map (unlike `ents.GetAll()`).


```lua
hook.Add("Think", "MyAddon.Think", function()
end)
```

Reason: `hook.Add` registers a callback on the named hook (`"Think"`), using `"MyAddon.Think"` as the unique identifier to allow later removal or replacement.


```lua
if IsValid(ent) then
    ent:Remove() -- safe to call methods here
end
```

Reason: `IsValid(ent)` returns `true` only when `ent` is non-nil, is an entity (or panel/NPC/etc.), and has not been removed from the game world, making it the single idiomatic guard against dangling entity references in Garry's Mod.


```lua
net.Receive("MyAddon.Sync", function(len, ply)
    -- handle the incoming message
end)
```

Reason: `net.Receive` registers a callback that fires whenever a net message with the given name arrives, providing the message length in bits and the sending player (server-side) or `nil` (client-side).


```lua
-- Pre-allocate once outside the hot path
local cached_ang = Angle()

local function GetZeroAngle()
    cached_ang.p = 0
    cached_ang.y = 0
    cached_ang.r = 0
    return cached_ang
end
```

Reason: `Angle()` allocates a new userdata each call, pressuring the garbage collector; reusing a single pre-allocated Angle and zeroing its three fields avoids per-frame allocation entirely.


```lua
local cfg_color = myaddon.config.color   -- cache the nested lookup once

local function Draw()
    surface.SetDrawColor(cfg_color)       -- fast local read every frame
end
```

Reason: Each `.` is a hash-table lookup at runtime; a `local` is a direct register access in LuaJIT's VM, so caching the value into a local eliminates repeated table traversals and is measurably faster in hot paths like `HUDPaint`.


```lua
ply:getDarkRPVar("job")
```

Reason: `getDarkRPVar` is DarkRP's dedicated accessor for shared player variables (job, salary, etc.) and is the supported API; `GetNWString("job")` bypasses DarkRP's networking layer and may return stale or empty values.


```lua
if a:DistToSqr(b) < threshold * threshold then
    -- within range
end
```

Reason: `DistToSqr` skips the square root, making it cheaper than `Distance` when you only need to compare against a threshold.


```lua
for _, ent in ents.Iterator() do
    -- operate on ent
end
```

Reason: `ents.Iterator()` is the wiki-recommended efficient iterator because, unlike `ents.GetAll()`, it does not allocate a new table of all entities on each call.


```lua
local nearbyEnts = ents.FindInSphere(ply:GetPos(), 512)
for _, ent in ipairs(nearbyEnts) do
    if IsValid(ent) and ent ~= ply then
        -- operate on ent
    end
end
```

Reason: `ents.FindInSphere` performs a single engine-side squared-distance check per entity with no PVS/visibility overhead, making it consistently the fastest `FindIn*` call in GMod benchmarks for a simple proximity query.


```lua
local function PlayersInRadius(pos, radius)
    local found = {}
    local r2 = radius * radius
    for _, ply in ipairs(player.GetAll()) do
        if ply:GetPos():DistToSqr(pos) <= r2 then
            found[#found + 1] = ply
        end
    end
    return found
end
```

Reason: `ents.FindInSphere` tests every entity on the server (often thousands of props, weapons, NPCs, etc.) before you even start filtering for players, whereas iterating `player.GetAll()` touches only the handful of connected players and `DistToSqr` avoids the square-root cost of a true distance check.


```lua
for i = 1, n do
end
```

Reason: The numeric `for` loop is faster because LuaJIT (used by GMod) compiles it to dedicated `FORPREP`/`FORLOOP` VM opcodes that handle the increment and bound check internally, avoiding the extra variable lookup, manual increment, and comparison instructions that a `while` loop requires each iteration.


```lua
-- Pattern A: one hook.Run, pass the full player table
hook.Add("Think", "BatchNotify", function()
    hook.Run("MyCustomLogic", player.GetAll())
end)

-- Pattern B: loop and call hook.Run per player
hook.Add("Think", "PerPlayerNotify", function()
    for _, ply in ipairs(player.GetAll()) do
        hook.Run("MyCustomLogic", ply)
    end
end)
```

Reason: Pattern A is faster because `hook.Run` has fixed per-call overhead (table lookup, handler iteration, vararg packing); calling it once per tick with the player table incurs that cost once, while Pattern B incurs it N times (once per player per tick), making the overhead scale linearly with player count.


CLI exited without a valid strict response.