MCPcopy
hub / github.com/tidwall/gjson / stringLessInsensitive

Function stringLessInsensitive

gjson.go:2336–2371  ·  view source on GitHub ↗
(a, b string)

Source from the content-addressed store, hash-verified

2334}
2335
2336func stringLessInsensitive(a, b string) bool {
2337 for i := 0; i < len(a) && i < len(b); i++ {
2338 if a[i] >= 'A' && a[i] <= 'Z' {
2339 if b[i] >= 'A' && b[i] <= 'Z' {
2340 // both are uppercase, do nothing
2341 if a[i] < b[i] {
2342 return true
2343 } else if a[i] > b[i] {
2344 return false
2345 }
2346 } else {
2347 // a is uppercase, convert a to lowercase
2348 if a[i]+32 < b[i] {
2349 return true
2350 } else if a[i]+32 > b[i] {
2351 return false
2352 }
2353 }
2354 } else if b[i] >= 'A' && b[i] <= 'Z' {
2355 // b is uppercase, convert b to lowercase
2356 if a[i] < b[i]+32 {
2357 return true
2358 } else if a[i] > b[i]+32 {
2359 return false
2360 }
2361 } else {
2362 // neither are uppercase
2363 if a[i] < b[i] {
2364 return true
2365 } else if a[i] > b[i] {
2366 return false
2367 }
2368 }
2369 }
2370 return len(a) < len(b)
2371}
2372
2373// parseAny parses the next value from a json string.
2374// A Result is returned when the hit param is set.

Callers 2

TestLessFunction · 0.85
LessMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestLessFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…