Skip to content

Commit a833295

Browse files
committed
Use new methods in go-properties-orderedmap to calculate subsets
1 parent c1bfd53 commit a833295

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

arduino/cores/board.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -145,36 +145,9 @@ func (b *Board) GeneratePropertiesForConfiguration(config string) (*properties.M
145145
// containing the properties required to identify the board. The returned sets
146146
// must not be changed by the caller.
147147
func (b *Board) GetIdentificationProperties() []*properties.Map {
148-
if b.identificationProperties != nil {
149-
return b.identificationProperties
148+
if b.identificationProperties == nil {
149+
b.identificationProperties = b.Properties.ExtractSubIndexSets("upload_port")
150150
}
151-
b.identificationProperties = []*properties.Map{}
152-
153-
portIDPropsSet := b.Properties.SubTree("upload_port")
154-
if portIDPropsSet.Size() == 0 {
155-
return b.identificationProperties
156-
}
157-
158-
// First check the identification properties with sub index "upload_port.N.xxx"
159-
idx := 0
160-
haveIndexedProperties := false
161-
for {
162-
idProps := portIDPropsSet.SubTree(fmt.Sprintf("%d", idx))
163-
idx++
164-
if idProps.Size() > 0 {
165-
haveIndexedProperties = true
166-
b.identificationProperties = append(b.identificationProperties, idProps)
167-
} else if idx > 1 {
168-
// Always check sub-id 0 and 1 (https://github.com/arduino/arduino-cli/issues/456)
169-
break
170-
}
171-
}
172-
173-
// if there are no subindexed then check the whole "upload_port.xxx"
174-
if !haveIndexedProperties {
175-
b.identificationProperties = append(b.identificationProperties, portIDPropsSet)
176-
}
177-
178151
return b.identificationProperties
179152
}
180153

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/fluxio/iohelpers v0.0.0-20160419043813-3a4dd67a94d2 // indirect
1717
github.com/fluxio/multierror v0.0.0-20160419044231-9c68d39025e5 // indirect
1818
github.com/gofrs/uuid v3.2.0+incompatible
19-
github.com/golang/protobuf v1.5.2
2019
github.com/h2non/filetype v1.0.8 // indirect
2120
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
2221
github.com/kr/text v0.2.0 // indirect
@@ -38,7 +37,6 @@ require (
3837
github.com/spf13/jwalterweatherman v1.0.0
3938
github.com/spf13/viper v1.6.2
4039
github.com/stretchr/testify v1.6.1
41-
github.com/xanzy/ssh-agent v0.2.1 // indirect
4240
go.bug.st/cleanup v1.0.0
4341
go.bug.st/downloader/v2 v2.1.1
4442
go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18
@@ -48,7 +46,7 @@ require (
4846
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125
4947
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 // indirect
5048
golang.org/x/text v0.3.6
51-
google.golang.org/genproto v0.0.0-20210504143626-3b2ad6ccc450 // indirect
49+
google.golang.org/genproto v0.0.0-20210504143626-3b2ad6ccc450
5250
google.golang.org/grpc v1.37.0
5351
google.golang.org/protobuf v1.26.0
5452
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect

0 commit comments

Comments
 (0)