Add buf pool to IdentQuote

This commit is contained in:
Patrick O'brien 2016-08-13 18:07:45 +10:00
parent 19b4b722e7
commit 8d92b5a9dd

View file

@ -30,16 +30,26 @@ func IdentQuote(s string) string {
return s return s
} }
buf := GetBuffer()
defer PutBuffer(buf)
splits := strings.Split(s, ".") splits := strings.Split(s, ".")
for i, split := range splits { for i, split := range splits {
if i != 0 {
buf.WriteByte('.')
}
if strings.HasPrefix(split, `"`) || strings.HasSuffix(split, `"`) || split == "*" { if strings.HasPrefix(split, `"`) || strings.HasSuffix(split, `"`) || split == "*" {
buf.WriteString(split)
continue continue
} }
splits[i] = fmt.Sprintf(`"%s"`, split) buf.WriteByte('"')
buf.WriteString(split)
buf.WriteByte('"')
} }
return strings.Join(splits, ".") return buf.String()
} }
// IdentQuoteSlice applies IdentQuote to a slice. // IdentQuoteSlice applies IdentQuote to a slice.