Skip to content

Convert injection mode from strings to bitfield constants#42

Merged
rjrodger merged 1 commit intodevfrom
claude/injection-mode-bitfield-5b2AW
Feb 16, 2026
Merged

Convert injection mode from strings to bitfield constants#42
rjrodger merged 1 commit intodevfrom
claude/injection-mode-bitfield-5b2AW

Conversation

@rjrodger
Copy link
Contributor

Summary

Refactored the injection mode system from string-based values to numeric bitfield constants for improved performance and type safety. This change affects the internal representation of injection modes throughout the codebase while maintaining the same functional behavior.

Key Changes

  • Mode Constants: Replaced string constants (S_MKEYPRE, S_MKEYPOST, S_MVAL) with numeric bitfield constants:

    • M_KEYPRE = 1
    • M_KEYPOST = 2
    • M_VAL = 4
  • Type Definition: Changed InjectMode type from 'key:pre' | 'key:post' | 'val' to number

  • Placement Checking: Updated checkPlacement() function signature to accept a single InjectMode bitfield instead of an array, using bitwise AND (&) operations for validation

  • Mode Name Mapping: Added MODENAME constant object to map numeric modes back to string representations for logging and debugging purposes

  • Exports: Added new constants (M_KEYPRE, M_KEYPOST, M_VAL, MODENAME) to public API exports

  • Updated All References: Changed all mode comparisons and assignments throughout the codebase to use the new numeric constants instead of string values

Implementation Details

  • The bitfield approach allows for efficient mode checking using bitwise operations
  • The MODENAME mapping preserves human-readable output in debug/logging contexts
  • All injection handlers, validators, and selectors were updated to use the new numeric mode constants
  • The Injection class constructor now initializes mode to M_VAL instead of the string 'val'
  • Mode comparisons in conditional statements now use numeric equality checks instead of string comparisons

https://claude.ai/code/session_01GSURzK61tcu7JjT19KWWbp

Replace string-based injection modes ('key:pre', 'key:post', 'val')
with bitfield constants (M_KEYPRE=1, M_KEYPOST=2, M_VAL=4). Update
InjectMode type to number, checkPlacement to use bitmask operations,
and export mode constants for external use.

https://claude.ai/code/session_01GSURzK61tcu7JjT19KWWbp
@rjrodger rjrodger merged commit 516d08b into dev Feb 16, 2026
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.

2 participants