diff --git a/commands.go b/commands.go index 263eaa2118f..e32a51e7699 100644 --- a/commands.go +++ b/commands.go @@ -125,9 +125,10 @@ type dropMeasurementCommand struct { } type createMeasurementSubcommand struct { - Name string `json:"name"` - Tags []map[string]string `json:"tags"` - Fields []*Field `json:"fields"` + Name string `json:"name"` + Tags []map[string]string `json:"tags"` + marshaledTags []string // local cache...don't marshal + Fields []*Field `json:"fields"` } type createMeasurementsIfNotExistsCommand struct { @@ -165,14 +166,16 @@ func (c *createMeasurementsIfNotExistsCommand) addSeriesIfNotExists(measurement m := c.addMeasurementIfNotExists(measurement) tagset := string(marshalTags(tags)) - for _, t := range m.Tags { - if string(marshalTags(t)) == tagset { + for _, t := range m.marshaledTags { + if t == tagset { // Series already present in subcommand, nothing to do. return } } // Tag-set needs to added to subcommand. m.Tags = append(m.Tags, tags) + // Store marshaled tags in local cache for performance. + m.marshaledTags = append(m.marshaledTags, tagset) return }