1// Copyright 2018 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5// +build amd64 arm arm64 ppc64le ppc64 s390x 6 7package bytealg 8 9//go:noescape 10func Count(b []byte, c byte) int 11 12//go:noescape 13func CountString(s string, c byte) int 14 15// A backup implementation to use by assembly. 16func countGeneric(b []byte, c byte) int { 17 n := 0 18 for _, x := range b { 19 if x == c { 20 n++ 21 } 22 } 23 return n 24} 25func countGenericString(s string, c byte) int { 26 n := 0 27 for i := 0; i < len(s); i++ { 28 if s[i] == c { 29 n++ 30 } 31 } 32 return n 33} 34