Skip to content

Hoist protocol_map to module-level constant PROTOCOL_MAP#231

Merged
marksull merged 2 commits intofeature/literal-support-copilotfrom
copilot/sub-pr-229
Mar 7, 2026
Merged

Hoist protocol_map to module-level constant PROTOCOL_MAP#231
marksull merged 2 commits intofeature/literal-support-copilotfrom
copilot/sub-pr-229

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

protocol_map inside get_protocol_number() was being rebuilt as a 143-entry dict on every call. Moved it to a module-level constant PROTOCOL_MAP so it's allocated once at import time.

Changes

  • fmcapi/api_objects/helper_functions.py: Extracted protocol_map from get_protocol_number() into a module-level PROTOCOL_MAP constant; function now references it directly.
# Before: dict rebuilt on every call
def get_protocol_number(protocol_name):
    protocol_map = { "TCP": "6", "UDP": "17", ... }  # ~143 entries
    return protocol_map.get(protocol_name.upper())

# After: allocated once at import time
PROTOCOL_MAP = { "TCP": "6", "UDP": "17", ... }

def get_protocol_number(protocol_name):
    return PROTOCOL_MAP.get(protocol_name.upper())

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on literal support feature implementation Hoist protocol_map to module-level constant PROTOCOL_MAP Mar 7, 2026
@marksull marksull marked this pull request as ready for review March 7, 2026 10:06
@marksull marksull merged commit e783e7a into feature/literal-support-copilot Mar 7, 2026
@marksull marksull deleted the copilot/sub-pr-229 branch March 7, 2026 10:07
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