Skip to content

Commit

Permalink
Merge pull request #2130 from influxdb/fix_mucho_marshaling
Browse files Browse the repository at this point in the history
make fewer calls to marshalTags
  • Loading branch information
toddboom committed Mar 31, 2015
2 parents 3eb0b04 + 40245da commit 1b6d185
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1b6d185

Please sign in to comment.