cvsuser 04/04/21 04:30:40
Modified: src string.c
Log:
put common slow part of string_equal and _compare into separate func
Revision Changes Path
1.198 +47 -38 parrot/src/string.c
Index: string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -w -r1.197 -r1.198
--- string.c 21 Apr 2004 11:06:13 -0000 1.197
+++ string.c 21 Apr 2004 11:30:40 -0000 1.198
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: string.c,v 1.197 2004/04/21 11:06:13 leo Exp $
+$Id: string.c,v 1.198 2004/04/21 11:30:40 leo Exp $
=head1 NAME
@@ -1644,6 +1644,49 @@
*/
+static INTVAL
+cmp_diff_repr(STRING *s1, STRING *s2)
+{
+
+ /* make this 3 more cases, rather than 6 */
+ INTVAL multiplier;
+ STRING *larger;
+ STRING *smaller;
+ INTVAL cmp;
+
+ if (s1->representation > s2->representation) {
+ larger = s1;
+ smaller = s2;
+ multiplier = 1;
+ }
+ else {
+ larger = s2;
+ smaller = s1;
+ multiplier = -1;
+ }
+
+ if (larger->representation == enum_stringrep_four) {
+ if (smaller->representation == enum_stringrep_two) {
+ COMPARE_STRINGS(Parrot_UInt4, Parrot_UInt2,
+ larger, smaller, cmp);
+ }
+ else {
+ /* smaller->representation == enum_stringrep_one */
+ COMPARE_STRINGS(Parrot_UInt4, Parrot_UInt1,
+ larger, smaller, cmp);
+ }
+ }
+ else {
+ /*
+ * larger->representation == enum_stringrep_two,
+ * smaller->representation == enum_stringrep_one
+ */
+ COMPARE_STRINGS(Parrot_UInt2, Parrot_UInt1, larger, smaller, cmp);
+ }
+
+ return cmp * multiplier;
+}
+
INTVAL
string_compare(struct Parrot_Interp *interpreter,
STRING *s1, STRING *s2)
@@ -1686,44 +1729,10 @@
return cmp;
}
else {
- /* make this 3 more cases, rather than 6 */
- INTVAL multiplier;
- STRING *larger;
- STRING *smaller;
-
- if (s1->representation > s2->representation) {
- larger = s1;
- smaller = s2;
- multiplier = 1;
- }
- else {
- larger = s2;
- smaller = s1;
- multiplier = -1;
- }
-
- if (larger->representation == enum_stringrep_four) {
- if (smaller->representation == enum_stringrep_two) {
- COMPARE_STRINGS(Parrot_UInt4, Parrot_UInt2,
- larger, smaller, cmp);
- }
- else {
- /* smaller->representation == enum_stringrep_one */
- COMPARE_STRINGS(Parrot_UInt4, Parrot_UInt1,
- larger, smaller, cmp);
+ return cmp_diff_repr(s1, s2);
}
}
- else {
- /*
- * larger->representation == enum_stringrep_two,
- * smaller->representation == enum_stringrep_one
- */
- COMPARE_STRINGS(Parrot_UInt2, Parrot_UInt1, larger, smaller, cmp);
- }
- return cmp * multiplier;
- }
-}
/*
@@ -1781,7 +1790,7 @@
/* all the fast shortcuts have been taken
* now just left with compare
*/
- return string_compare(interpreter, s1, s2);
+ return cmp_diff_repr(s1, s2);
}
}