Merge pull request #211 from sosiska/patch-1

Rewrite some if-else-if-else chains as a switch
This commit is contained in:
Vasily Romanov
2019-03-12 17:32:42 +03:00
committed by GitHub
2 changed files with 8 additions and 6 deletions
+4 -3
View File
@@ -427,9 +427,10 @@ func lowerFirst(s string) string {
for i := range s {
ch := s[i]
if isUpper(ch) {
if i == 0 {
switch {
case i == 0:
str += string(ch + 32)
} else if !foundLower { // Currently just a stream of capitals, eg JSONRESTS[erver]
case !foundLower: // Currently just a stream of capitals, eg JSONRESTS[erver]
if strlen > (i+1) && isLower(s[i+1]) {
// Next char is lower, keep this a capital
str += string(ch)
@@ -437,7 +438,7 @@ func lowerFirst(s string) string {
// Either at end of string or next char is capital
str += string(ch + 32)
}
} else {
default:
str += string(ch)
}
} else {
+4 -3
View File
@@ -521,11 +521,12 @@ func (r *Lexer) SkipRecursive() {
r.scanToken()
var start, end byte
if r.token.delimValue == '{' {
switch r.token.delimValue {
case '{':
start, end = '{', '}'
} else if r.token.delimValue == '[' {
case '[':
start, end = '[', ']'
} else {
default:
r.consume()
return
}