File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 17
17
idAlphabet = []byte ("abcdefghijklmnopqrstuvwxyz" )
18
18
smartQuoteRgx = regexp .MustCompile (`^(?i)"?[a-z_][_a-z0-9\-]*"?(\."?[_a-z][_a-z0-9]*"?)*(\.\*)?$` )
19
19
20
- rgxEnum = regexp .MustCompile (`^enum(\.[a-zA-Z0-9_]+)?\([^\)]+\)$` )
21
- rgxWhitespace = regexp .MustCompile (`\s` )
22
- rgxAlphanumeric = regexp .MustCompile ("[^a-zA-Z0-9 ]+" )
20
+ rgxEnum = regexp .MustCompile (`^enum(\.[a-zA-Z0-9_]+)?\([^\)]+\)$` )
21
+ rgxWhitespace = regexp .MustCompile (`\s` )
22
+ rgxAlphanumericAndUnderscores = regexp .MustCompile ("[^a-zA-Z0-9_ ]+" )
23
23
)
24
24
25
25
func AddUppercase (s string ) {
@@ -252,7 +252,21 @@ func TitleCase(n string) string {
252
252
return val
253
253
}
254
254
255
- name := []byte (rgxAlphanumeric .ReplaceAllLiteralString (n , "_" ))
255
+ cleanN := rgxAlphanumericAndUnderscores .ReplaceAllLiteralString (n , "_" )
256
+
257
+ // If the string is made up of only uppercase letters and underscores,
258
+ // then return as is and do not strip the underscores
259
+ // This keeps strings such as PUBLIC_KEY readable and not make it PUBLICKEY
260
+ if len (n ) == len (cleanN ) && n == strings .ToUpper (n ) {
261
+ // Cache the title case as the same string
262
+ mut .Lock ()
263
+ titleCaseCache [n ] = n
264
+ mut .Unlock ()
265
+
266
+ return n
267
+ }
268
+
269
+ name := []byte (cleanN )
256
270
ln := len (name )
257
271
buf := GetBuffer ()
258
272
You can’t perform that action at this time.
0 commit comments