Skip to content

Commit

Permalink
core.packet: revert globalization of newly exported variables and fun…
Browse files Browse the repository at this point in the history
…ctions

Recent changes ([1], [2], [3]) exposed some previously internal variables
and functions from core.packet. This patch restores local bindings for
those within core.packet in order to maintain performance.

[1] 6174563 (snabbco#1450)
[2] ee4e42d (snabbco#1450)
[3] 9f0694f (snabbco#1288)
  • Loading branch information
eugeneia committed Jan 18, 2022
1 parent 2d7341e commit 247ef95
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/packet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ default_headroom = 256
-- things aligned at least this much.
minimum_alignment = 2

-- Copy read-only constants to locals
local max_payload, packet_alignment, default_headroom, minimum_alignment =
max_payload, packet_alignment, default_headroom, minimum_alignment

local function get_alignment (addr, alignment)
-- Precondition: alignment is a power of 2.
return bit.band(addr, alignment - 1)
Expand Down Expand Up @@ -273,6 +277,8 @@ function account_free (p)
counter.add(engine.freebits, (12 + 8 + math.max(p.length, 60) + 4) * 8)
end

local free_internal, account_free =
free_internal, account_free
function free (p)
account_free(p)
free_internal(p)
Expand Down

0 comments on commit 247ef95

Please sign in to comment.