libgo: update to Go 1.11
[official-gcc.git] / libgo / go / internal / bytealg / count_generic.go
blob5a0643011e4ddc3f4d3d95a259d379ac73d6a729
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.
5 // -build !amd64,!arm64
7 package bytealg
9 func Count(b []byte, c byte) int {
10 n := 0
11 for _, x := range b {
12 if x == c {
13 n++
16 return n
19 func CountString(s string, c byte) int {
20 n := 0
21 for i := 0; i < len(s); i++ {
22 if s[i] == c {
23 n++
26 return n