MCPcopy Create free account
hub / github.com/dop251/goja / index

Method index

string_unicode.go:503–529  ·  view source on GitHub ↗
(substr String, start int)

Source from the content-addressed store, hash-verified

501}
502
503func (s unicodeString) index(substr String, start int) int {
504 var ss []uint16
505 a, u := devirtualizeString(substr)
506 if u != nil {
507 ss = u[1:]
508 } else {
509 ss = make([]uint16, len(a))
510 for i := 0; i < len(a); i++ {
511 ss[i] = uint16(a[i])
512 }
513 }
514 s1 := s[1:]
515 // TODO: optimise
516 end := len(s1) - len(ss)
517 for start <= end {
518 for i := 0; i < len(ss); i++ {
519 if s1[start+i] != ss[i] {
520 goto nomatch
521 }
522 }
523
524 return start
525 nomatch:
526 start++
527 }
528 return -1
529}
530
531func (s unicodeString) lastIndex(substr String, start int) int {
532 var ss []uint16

Callers

nothing calls this directly

Calls 1

devirtualizeStringFunction · 0.85

Tested by

no test coverage detected