toUpper converts s to uppercase using a pooled byte buffer for short strings.
(s string)
| 166 | |
| 167 | // toUpper converts s to uppercase using a pooled byte buffer for short strings. |
| 168 | func toUpper(s string) string { |
| 169 | n := len(s) |
| 170 | var upper []byte |
| 171 | if n <= 32 { |
| 172 | bufPtr := kwBufPool.Get().(*[]byte) |
| 173 | upper = (*bufPtr)[:n] |
| 174 | defer kwBufPool.Put(bufPtr) |
| 175 | } else { |
| 176 | upper = make([]byte, n) |
| 177 | } |
| 178 | for i := 0; i < n; i++ { |
| 179 | c := s[i] |
| 180 | if c >= 'a' && c <= 'z' { |
| 181 | upper[i] = c - 32 |
| 182 | } else { |
| 183 | upper[i] = c |
| 184 | } |
| 185 | } |
| 186 | return string(upper) |
| 187 | } |
| 188 | |
| 189 | // identifierKeywordType remaps identifiers that carry SQL keyword values to |
| 190 | // their specific models.TokenType. This is conservative: only keywords that |
no test coverage detected