Created
December 19, 2012 23:49
-
-
Save tyler-smith/4341815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
rb_str_cmp(VALUE str1, VALUE str2) | |
{ | |
long len1, len2; | |
const char *ptr1, *ptr2; | |
int retval; | |
if (str1 == str2) return 0; | |
RSTRING_GETMEM(str1, ptr1, len1); | |
RSTRING_GETMEM(str2, ptr2, len2); | |
if (ptr1 == ptr2 || (retval = memcmp(ptr1, ptr2, lesser(len1, len2))) == 0) { | |
if (len1 == len2) { | |
if (!rb_str_comparable(str1, str2)) { | |
if (ENCODING_GET(str1) > ENCODING_GET(str2)) | |
return 1; | |
return -1; | |
} | |
return 0; | |
} | |
if (len1 > len2) return 1; | |
return -1; | |
} | |
if (retval > 0) return 1; | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment