github.com/kamalshkeir/kencoding@v0.0.2-0.20230409043843-44b609a0475a/ascii/equal_fold.go (about)

     1  //go:generate go run equal_fold_asm.go -out equal_fold_amd64.s -stubs equal_fold_amd64.go
     2  package ascii
     3  
     4  import (
     5  	"github.com/kamalshkeir/kasm/ascii"
     6  )
     7  
     8  // EqualFold is a version of bytes.EqualFold designed to work on ASCII input
     9  // instead of UTF-8.
    10  //
    11  // When the program has guarantees that the input is composed of ASCII
    12  // characters only, it allows for greater optimizations.
    13  func EqualFold(a, b []byte) bool {
    14  	return ascii.EqualFold(a, b)
    15  }
    16  
    17  func HasPrefixFold(s, prefix []byte) bool {
    18  	return ascii.HasPrefixFold(s, prefix)
    19  }
    20  
    21  func HasSuffixFold(s, suffix []byte) bool {
    22  	return ascii.HasSuffixFold(s, suffix)
    23  }
    24  
    25  // EqualFoldString is a version of strings.EqualFold designed to work on ASCII
    26  // input instead of UTF-8.
    27  //
    28  // When the program has guarantees that the input is composed of ASCII
    29  // characters only, it allows for greater optimizations.
    30  func EqualFoldString(a, b string) bool {
    31  	return ascii.EqualFoldString(a, b)
    32  }
    33  
    34  func HasPrefixFoldString(s, prefix string) bool {
    35  	return ascii.HasPrefixFoldString(s, prefix)
    36  }
    37  
    38  func HasSuffixFoldString(s, suffix string) bool {
    39  	return ascii.HasSuffixFoldString(s, suffix)
    40  }