mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
- replaced gofmt expression formatting algorithm with
rsc's algorithm - applied gofmt -w misc src - partial CL (last chunk) R=rsc, r http://go/go-review/1024041
This commit is contained in:
parent
baba292998
commit
3bb0032cd6
121 changed files with 750 additions and 750 deletions
|
|
@ -41,9 +41,9 @@ func Count(s, sep string) int {
|
|||
c := sep[0];
|
||||
n := 0;
|
||||
for i := 0; i+len(sep) <= len(s); i++ {
|
||||
if s[i] == c && (len(sep) == 1 || s[i : i+len(sep)] == sep) {
|
||||
if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) {
|
||||
n++;
|
||||
i += len(sep)-1;
|
||||
i += len(sep) - 1;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
|
|
@ -57,7 +57,7 @@ func Index(s, sep string) int {
|
|||
}
|
||||
c := sep[0];
|
||||
for i := 0; i+n <= len(s); i++ {
|
||||
if s[i] == c && (n == 1 || s[i : i+n] == sep) {
|
||||
if s[i] == c && (n == 1 || s[i:i+n] == sep) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
|
@ -71,8 +71,8 @@ func LastIndex(s, sep string) int {
|
|||
return len(s)
|
||||
}
|
||||
c := sep[0];
|
||||
for i := len(s)-n; i >= 0; i-- {
|
||||
if s[i] == c && (n == 1 || s[i : i+n] == sep) {
|
||||
for i := len(s) - n; i >= 0; i-- {
|
||||
if s[i] == c && (n == 1 || s[i:i+n] == sep) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
|
@ -93,11 +93,11 @@ func genSplit(s, sep string, sepSave, n int) []string {
|
|||
a := make([]string, n);
|
||||
na := 0;
|
||||
for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
|
||||
if s[i] == c && (len(sep) == 1 || s[i : i+len(sep)] == sep) {
|
||||
if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) {
|
||||
a[na] = s[start : i+sepSave];
|
||||
na++;
|
||||
start = i+len(sep);
|
||||
i += len(sep)-1;
|
||||
start = i + len(sep);
|
||||
i += len(sep) - 1;
|
||||
}
|
||||
}
|
||||
a[na] = s[start:len(s)];
|
||||
|
|
@ -125,7 +125,7 @@ func Join(a []string, sep string) string {
|
|||
if len(a) == 1 {
|
||||
return a[0]
|
||||
}
|
||||
n := len(sep)*(len(a)-1);
|
||||
n := len(sep) * (len(a) - 1);
|
||||
for i := 0; i < len(a); i++ {
|
||||
n += len(a[i])
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ func HasPrefix(s, prefix string) bool {
|
|||
|
||||
// HasSuffix tests whether the string s ends with suffix.
|
||||
func HasSuffix(s, suffix string) bool {
|
||||
return len(s) >= len(suffix) && s[len(s)-len(suffix) : len(s)] == suffix
|
||||
return len(s) >= len(suffix) && s[len(s)-len(suffix):len(s)] == suffix
|
||||
}
|
||||
|
||||
// Map returns a copy of the string s with all its characters modified
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue