mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Merge pull request #211 from sosiska/patch-1
Rewrite some if-else-if-else chains as a switch
This commit is contained in:
+4
-3
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user