Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -C 3 -r Python-3.2.3_orig/Objects/unicodeobject.c Python-3.2.3/Objects/unicodeobject.c
- *** Python-3.2.3_orig/Objects/unicodeobject.c 2012-09-06 16:57:35.000000000 +0200
- --- Python-3.2.3/Objects/unicodeobject.c 2012-09-06 17:26:10.000000000 +0200
- ***************
- *** 7264,7269 ****
- --- 7264,7298 ----
- #else
- + #include <stdint.h>
- + #include <stdbool.h>
- + static uint64_t strCmpEq;
- + static uint64_t strCmpLt;
- + static uint64_t strCmpGt;
- + static uint64_t totalChars;
- + static uint64_t comparedChars;
- +
- + bool strEq(PyUnicodeObject *x, const char *y) {
- + int i;
- + if (strlen(y) != x->length) return false;
- + for (i = 0; i < x->length; i++) {
- + if (x->str[i] != y[i]) {
- + return false;
- + }
- + }
- + return true;
- + }
- +
- + void record(int returnVal) {
- + if (returnVal == -1) {
- + strCmpLt++;
- + } else if (returnVal == 0) {
- + strCmpEq++;
- + } else {
- + strCmpGt++;
- + }
- + }
- +
- static int
- unicode_compare(PyUnicodeObject *str1, PyUnicodeObject *str2)
- {
- ***************
- *** 7274,7293 ****
- len1 = str1->length;
- len2 = str2->length;
- while (len1 > 0 && len2 > 0) {
- Py_UNICODE c1, c2;
- c1 = *s1++;
- c2 = *s2++;
- ! if (c1 != c2)
- ! return (c1 < c2) ? -1 : 1;
- len1--; len2--;
- }
- !
- ! return (len1 < len2) ? -1 : (len1 != len2);
- }
- #endif
- --- 7303,7335 ----
- len1 = str1->length;
- len2 = str2->length;
- + totalChars += (len1 < len2) ? len1 : len2;
- + if (strEq(str1, "pleasedumpstats")) {
- + fprintf(stderr, "strCmpEq %ld\n", strCmpEq);
- + fprintf(stderr, "strCmpLt %ld\n", strCmpLt);
- + fprintf(stderr, "strCmpGt %ld\n", strCmpGt);
- + fprintf(stderr, "strCmpTc %ld\n", totalChars);
- + fprintf(stderr, "strCmpCc %ld\n", comparedChars);
- + }
- while (len1 > 0 && len2 > 0) {
- + comparedChars++;
- Py_UNICODE c1, c2;
- c1 = *s1++;
- c2 = *s2++;
- ! if (c1 != c2) {
- ! int returnVal = (c1 < c2) ? -1 : 1;
- ! record(returnVal);
- ! return returnVal;
- ! }
- len1--; len2--;
- }
- ! int returnVal = (len1 < len2) ? -1 : (len1 != len2);
- ! record(returnVal);
- ! return returnVal;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement