Optimize callsign matching performance

Co-authored-by: SpudGunMan <12676665+SpudGunMan@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-28 19:14:01 +00:00
parent ee4f910d6e
commit 2b0d7267b5
+13 -4
View File
@@ -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():