Avoid copying slice when escaping/unescaping tags

byte.Replace will return a copy of the input even when nothing has
been replaced.  This is called in lower level query execution and
create some garbage that isn't necessary.
pull/5289/head
Jason Wilder 2016-01-06 12:45:29 -07:00
parent 2f7a0090c1
commit 59e08606cb
1 changed files with 6 additions and 2 deletions

View File

@ -993,14 +993,18 @@ func unescapeMeasurement(in []byte) []byte {
func escapeTag(in []byte) []byte {
for b, esc := range tagEscapeCodes {
in = bytes.Replace(in, []byte{b}, esc, -1)
if bytes.Contains(in, []byte{b}) {
in = bytes.Replace(in, []byte{b}, esc, -1)
}
}
return in
}
func unescapeTag(in []byte) []byte {
for b, esc := range tagEscapeCodes {
in = bytes.Replace(in, esc, []byte{b}, -1)
if bytes.Contains(in, []byte{b}) {
in = bytes.Replace(in, esc, []byte{b}, -1)
}
}
return in
}