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
parent
2f7a0090c1
commit
59e08606cb
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue