| 225 | } |
| 226 | |
| 227 | func (b *StringBuilder) WriteUTF8String(s string) { |
| 228 | firstUnicodeIdx := 0 |
| 229 | if b.ascii() { |
| 230 | for i := 0; i < len(s); i++ { |
| 231 | if s[i] >= utf8.RuneSelf { |
| 232 | b.switchToUnicode(len(s)) |
| 233 | b.unicodeBuilder.writeASCIIString(s[:i]) |
| 234 | firstUnicodeIdx = i |
| 235 | goto unicode |
| 236 | } |
| 237 | } |
| 238 | b.asciiBuilder.WriteString(s) |
| 239 | return |
| 240 | } |
| 241 | unicode: |
| 242 | for _, r := range s[firstUnicodeIdx:] { |
| 243 | b.unicodeBuilder.writeRuneFast(r) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | func (b *StringBuilder) writeASCII(s string) { |
| 248 | if b.ascii() { |