Skip to content

refactor: move dynamic import resolution to unit initialization#63

Merged
Xor-el merged 1 commit intomasterfrom
enhancement/cleanup-arm-detection-logic
Apr 13, 2026
Merged

refactor: move dynamic import resolution to unit initialization#63
Xor-el merged 1 commit intomasterfrom
enhancement/cleanup-arm-detection-logic

Conversation

@Xor-el
Copy link
Copy Markdown
Owner

@Xor-el Xor-el commented Apr 13, 2026

Summary

Move dynamic library symbol resolution (dlopen/dlsym) from lazy
per-call resolution to one-time unit initialization for ARM hardware
capability detection on Linux, Android, BSD, and macOS (Darwin).

Changes

HlpArmHwCapProvider.pas (Linux/Android and BSD)

  • Renamed ResolveOnce to ResolveDynamicImports and removed the
    manual FResolved boolean guard, since the initialization section
    guarantees single execution.
  • Removed ResolveOnce calls from GetHwCap and GetHwCap2 — the
    function pointers are already resolved by the time any caller can
    reach them.
  • Added an initialization section that calls
    ResolveDynamicImports at unit load time.
  • Relaxed visibility from strict private to private so the
    initialization section can access the method.

HlpDarwinSysCtl.pas (macOS/iOS)

  • Same refactor: renamed ResolveOnce to ResolveDynamicImports,
    removed the FResolved guard, removed the call from HasFeature,
    and moved resolution to an initialization section.

Rationale

The previous pattern resolved imports lazily on first use with a
boolean guard. This worked but added a branch to every call of
GetHwCap, GetHwCap2, and HasFeature. Since these function
pointers never change after resolution, performing the dlopen/dlsym
once at unit initialization is simpler, removes the redundant flag
field, and eliminates repeated nil-check overhead on the hot path.

@Xor-el Xor-el merged commit adeb731 into master Apr 13, 2026
8 checks passed
@Xor-el Xor-el deleted the enhancement/cleanup-arm-detection-logic branch April 13, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant