[Checkins] SVN: BTrees/branches/pure_python/ Scrap the '_set_operation' mega-function.
Tres Seaver
cvs-admin at zope.org
Tue Dec 4 20:17:56 UTC 2012
Log message for revision 128512:
Scrap the '_set_operation' mega-function.
Changed:
_U BTrees/branches/pure_python/
U BTrees/branches/pure_python/BTrees/_base.py
-=-
Modified: BTrees/branches/pure_python/BTrees/_base.py
===================================================================
--- BTrees/branches/pure_python/BTrees/_base.py 2012-12-04 20:17:55 UTC (rev 128511)
+++ BTrees/branches/pure_python/BTrees/_base.py 2012-12-04 20:17:56 UTC (rev 128512)
@@ -1136,71 +1136,6 @@
_p_resolveConflict = _Tree._p_resolveConflict
-def _set_operation(s1, s2,
- usevalues1=False, usevalues2=False,
- w1=1, w2=1,
- c1=True, c12=True, c2=True):
- MERGE_DEFAULT = getattr(s1, 'MERGE_DEFAULT', None)
- i1 = _SetIteration(s1, usevalues1, MERGE_DEFAULT)
- i2 = _SetIteration(s2, usevalues2, MERGE_DEFAULT)
- merge = i1.useValues or i2.useValues
- MERGE = getattr(s1, 'MERGE', None)
- if merge:
- MERGE_WEIGHT = getattr(s1, 'MERGE_WEIGHT')
- if MERGE is None and c12 and i1.useValues and i2.useValues:
- raise TypeError("invalid set operation")
-
- if (not i1.useValues) and i2.useValues:
- t = i1; i1 = i2; i2 = t
- t = w1; w1 = w2; w2 = t
- t = c1; c1 = c2; c2 = t
-
- if MERGE_DEFAULT is None:
- if i1.useValues:
- if (not i2.useValues) and c2:
- raise TypeError("invalid set operation")
- else:
- if c1 or c12:
- raise TypeError("invalid set operation")
-
- r = s1._mapping_type()
-
- def copy(i, w):
- r._keys.append(i.key)
- r._values.append(MERGE_WEIGHT(i.value, w))
- else:
- r = s1._set_type()
- def copy(i, w):
- r._keys.append(i.key)
-
- while i1.active and i2.active:
- cmp_ = cmp(i1.key, i2.key)
- if cmp_ < 0:
- if c1:
- copy(i1, w1)
- i1.advance()
- elif cmp_ == 0:
- if c12:
- r._keys.append(i1.key)
- if merge:
- r._values.append(MERGE(i1.value, w1, i2.value, w2))
- i1.advance()
- i2.advance()
- else:
- if c2:
- copy(i2, w2)
- i2.advance()
- if c1:
- while i1.active:
- copy(i1, w1)
- i1.advance()
- if c2:
- while i2.active:
- copy(i2, w2)
- i2.advance()
- return r
-
-
class set_operation(object):
def __init__(self, func, set_type):
@@ -1214,7 +1149,6 @@
def difference(set_type, o1, o2):
if o1 is None or o2 is None:
return o1
- #return _set_operation(o1, o2, 1, 0, 1, 0, 1, 0, 0)
i1 = _SetIteration(o1, True, 0)
i2 = _SetIteration(o2, False, 0)
if i1.useValues:
@@ -1246,7 +1180,6 @@
return o2
if o2 is None:
return o1
- #return _set_operation(o1, o2, 0, 0, 1, 1, 1, 1, 1)
i1 = _SetIteration(o1, False, 0)
i2 = _SetIteration(o2, False, 0)
result = o1._set_type()
@@ -1277,7 +1210,6 @@
return o2
if o2 is None:
return o1
- #return _set_operation(o1, o2, 0, 0, 1, 1, 0, 1, 0)
i1 = _SetIteration(o1, False, 0)
i2 = _SetIteration(o2, False, 0)
result = o1._set_type()
@@ -1302,7 +1234,6 @@
return w2, o2
if o2 is None:
return w1, o1
- #return 1, _set_operation(o1, o2, 1, 1, w1, w2, 1, 1, 1)
MERGE_DEFAULT = getattr(o1, 'MERGE_DEFAULT', None)
i1 = _SetIteration(o1, True, MERGE_DEFAULT)
i2 = _SetIteration(o2, True, MERGE_DEFAULT)
@@ -1352,7 +1283,6 @@
return w2, o2
if o2 is None:
return w1, o1
- #result = _set_operation(o1, o2, 1, 1, w1, w2, 0, 1, 0)
MERGE_DEFAULT = getattr(o1, 'MERGE_DEFAULT', None)
i1 = _SetIteration(o1, True, MERGE_DEFAULT)
i2 = _SetIteration(o2, True, MERGE_DEFAULT)
More information about the checkins
mailing list