MCPcopy Index your code
hub / github.com/dop251/goja / WriteUTF8String

Method WriteUTF8String

string_unicode.go:227–245  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

225}
226
227func (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 }
241unicode:
242 for _, r := range s[firstUnicodeIdx:] {
243 b.unicodeBuilder.writeRuneFast(r)
244 }
245}
246
247func (b *StringBuilder) writeASCII(s string) {
248 if b.ascii() {

Callers 2

TestStringBuilderFunction · 0.95
WriteToValueBuilderMethod · 0.80

Calls 5

asciiMethod · 0.95
switchToUnicodeMethod · 0.95
writeASCIIStringMethod · 0.80
WriteStringMethod · 0.80
writeRuneFastMethod · 0.80

Tested by 1

TestStringBuilderFunction · 0.76