You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
427 B

  1. package internal
  2. import "github.com/go-redis/redis/internal/util"
  3. func ToLower(s string) string {
  4. if isLower(s) {
  5. return s
  6. }
  7. b := make([]byte, len(s))
  8. for i := range b {
  9. c := s[i]
  10. if c >= 'A' && c <= 'Z' {
  11. c += 'a' - 'A'
  12. }
  13. b[i] = c
  14. }
  15. return util.BytesToString(b)
  16. }
  17. func isLower(s string) bool {
  18. for i := 0; i < len(s); i++ {
  19. c := s[i]
  20. if c >= 'A' && c <= 'Z' {
  21. return false
  22. }
  23. }
  24. return true
  25. }