From 2b0d7267b53992a4069b58be7fbce41c0286f0d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:14:01 +0000 Subject: [PATCH] Optimize callsign matching performance Co-authored-by: SpudGunMan <12676665+SpudGunMan@users.noreply.github.com> --- modules/radio.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/radio.py b/modules/radio.py index f985286..4b8dd9e 100644 --- a/modules/radio.py +++ b/modules/radio.py @@ -451,15 +451,24 @@ def check_callsign_match(message, callsigns): for callsign in callsigns: callsign_upper = callsign.upper() + # Pre-compute patterns for portable/mobile suffixes + callsign_with_slash = callsign_upper + '/' + callsign_with_dash = callsign_upper + '-' + slash_callsign = '/' + callsign_upper + dash_callsign = '-' + callsign_upper + # Check if callsign appears as a complete word if callsign_upper in words: return True - # Also check for callsigns in compound forms like "K7MHI/P" or "K7MHI-7" + + # Check for callsigns in compound forms like "K7MHI/P" or "K7MHI-7" for word in words: - if word.startswith(callsign_upper + '/') or word.startswith(callsign_upper + '-'): - return True - if word.endswith('/' + callsign_upper) or word.endswith('-' + callsign_upper): + if (word.startswith(callsign_with_slash) or + word.startswith(callsign_with_dash) or + word.endswith(slash_callsign) or + word.endswith(dash_callsign)): return True + return False async def wsjtxMonitor():