Skip to content

Commit 290866d

Browse files
committed
Perform regexp compile at package level
1 parent 0cbc3d5 commit 290866d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arduino/cores/packagemanager/loader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ func convertLegacyPlatformToPluggableDiscovery(platform *cores.PlatformRelease)
420420
}
421421
}
422422

423+
var netPropRegexp = regexp.MustCompile(`\{upload\.network\.([^}]+)\}`)
424+
423425
func convertLegacyNetworkPatternToPluggableDiscovery(props *properties.Map, newToolName string) *properties.Map {
424426
pattern, ok := props.GetOk("upload.network_pattern")
425427
if !ok {
@@ -434,7 +436,6 @@ func convertLegacyNetworkPatternToPluggableDiscovery(props *properties.Map, newT
434436
pattern = strings.ReplaceAll(pattern, "{network.password}", "{upload.field.password}")
435437
}
436438
// Search for "{upload.network.PROPERTY}"" and convert it to "{upload.port.property.PROPERTY}"
437-
netPropRegexp := regexp.MustCompile(`\{upload\.network\.([^}]+)\}`)
438439
for netPropRegexp.MatchString(pattern) {
439440
netProp := netPropRegexp.FindStringSubmatch(pattern)[1]
440441
pattern = strings.ReplaceAll(pattern, "{upload.network."+netProp+"}", "{upload.port.properties."+netProp+"}")

0 commit comments

Comments
 (0)