Skip to content

Commit de7f12a

Browse files
committed
Remove redundant map merging in GetDxccInfo, use internal maps directly
1 parent b4113fc commit de7f12a

1 file changed

Lines changed: 6 additions & 26 deletions

File tree

backend/dxcc/client.go

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,30 +1065,11 @@ func (c *Client) GetDxccInfo(ctx context.Context, callsign string, lookupDate *t
10651065
// 1. Normalize and check exceptions first (as per PHP logic)
10661066
normalizedCall := strings.ToUpper(strings.TrimSpace(callsign))
10671067
logging.Debug("DXCC lookup requested for callsign: %s (normalized: %s)", callsign, normalizedCall)
1068-
// Merge internal maps with exported maps (exported maps override internal but do not hide other keys)
1069-
exceptions := make(map[string]DxccException)
1070-
for k, v := range c.exceptionsMap {
1071-
exceptions[k] = v
1072-
}
1073-
for k, v := range c.ExceptionsMap {
1074-
exceptions[k] = v
1075-
}
1076-
1077-
prefixes := make(map[string]DxccPrefix)
1078-
for k, v := range c.prefixesMap {
1079-
prefixes[k] = v
1080-
}
1081-
for k, v := range c.PrefixesMap {
1082-
prefixes[k] = v
1083-
}
10841068

1085-
entities := make(map[int]DxccEntity)
1086-
for k, v := range c.entitiesMap {
1087-
entities[k] = v
1088-
}
1089-
for k, v := range c.EntitiesMap {
1090-
entities[k] = v
1091-
}
1069+
// Use internal maps directly (exported maps point to the same data, synced in loadMapsFromDB)
1070+
exceptions := c.exceptionsMap
1071+
prefixes := c.prefixesMap
1072+
entities := c.entitiesMap
10921073

10931074
if exc, ok := exceptions[normalizedCall]; ok {
10941075
// Check validity period if a lookupDate is provided
@@ -1104,9 +1085,8 @@ func (c *Client) GetDxccInfo(ctx context.Context, callsign string, lookupDate *t
11041085
// 2. Perform callsign prefix parsing to get the effective prefix
11051086
effectivePrefix := c.determineEffectivePrefix(normalizedCall)
11061087
logging.Debug("DXCC determined effective prefix: %q for callsign %s", effectivePrefix, normalizedCall)
1107-
// Diagnostic: show which maps we're using for this lookup
1108-
logging.Debug("DXCC using maps for lookup: prefixes=%d exceptions=%d entities=%d (exported prefixes set? %t)",
1109-
len(prefixes), len(exceptions), len(entities), len(c.PrefixesMap) != 0)
1088+
logging.Debug("DXCC using maps for lookup: prefixes=%d exceptions=%d entities=%d",
1089+
len(prefixes), len(exceptions), len(entities))
11101090
if effectivePrefix == "" {
11111091
// If prefix parsing yields nothing, return the "- NONE -" entity
11121092
if entity, ok := entities[0]; ok { // ADIF 0 is for NONE

0 commit comments

Comments
 (0)