config.lua: cache all defaults on config table after first load #334

Open
opened 2026-07-10 08:52:17 +00:00 by the.auditor · 0 comments
Owner

After PR #333, config.lua uses __index metamethod for deferred I/O. os and arch are cached on config via rawset after first access, but default values (from config_values) are not cached on config — every access hits __indexload_config_file() (no-op) → config_values[k].

The overhead is negligible but inconsistent with the os/arch caching pattern. Recommend updating __index to rawset cache for all fields after first access:

load_config_file()
local v = config_values[k]
rawset(t, k, v)
return v

Ref: PR #333

After PR #333, `config.lua` uses `__index` metamethod for deferred I/O. `os` and `arch` are cached on `config` via `rawset` after first access, but default values (from `config_values`) are not cached on `config` — every access hits `__index` → `load_config_file()` (no-op) → `config_values[k]`. The overhead is negligible but inconsistent with the `os`/`arch` caching pattern. Recommend updating `__index` to `rawset` cache for all fields after first access: ```lua load_config_file() local v = config_values[k] rawset(t, k, v) return v ``` Ref: PR #333
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/qpkg#334
No description provided.