mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
80a2183b46
Replace switch statement in sa2addrlist() with memory-efficient lookup table following mruby's memory-first design philosophy. Uses compact structure with only valid address family entries instead of wasteful 256-entry array. Changes: - Add af_info_t structure for address family metadata - Create compact af_table[] with only valid entries (~6-8 families) - Replace manual switch with get_af_info() linear search lookup - Support platform-specific families (AF_UNIX, AF_LOCAL, AF_LINK, etc.) - Use offset-based port extraction for better performance Performance characteristics: - O(n) linear search where n=6-8 (negligible vs switch statement) - Eliminates branch prediction overhead - Easier addition of new address families - Consistent optimization pattern following mruby memory priority Co-Authored-By: Claude <noreply@anthropic.com>