mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
More logic correction: RemoveOverlap should always create new tree. Add a
parameter to record whether changes actually happened. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95073 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b413bc1403
commit
bd46725476
@ -131,31 +131,31 @@ private:
|
|||||||
|
|
||||||
// Remove all overlaps from T.
|
// Remove all overlaps from T.
|
||||||
TreeTy *RemoveAllOverlaps(TreeTy *T, key_type_ref K) {
|
TreeTy *RemoveAllOverlaps(TreeTy *T, key_type_ref K) {
|
||||||
TreeTy *OldTree, *NewTree;
|
bool Changed;
|
||||||
NewTree = T;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
OldTree = NewTree;
|
Changed = false;
|
||||||
NewTree = RemoveOverlap(OldTree, K);
|
T = RemoveOverlap(T, K, Changed);
|
||||||
} while (NewTree != OldTree);
|
MarkImmutable(T);
|
||||||
|
} while (Changed);
|
||||||
|
|
||||||
return NewTree;
|
return T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove one overlap from T.
|
// Remove one overlap from T.
|
||||||
TreeTy *RemoveOverlap(TreeTy *T, key_type_ref K) {
|
TreeTy *RemoveOverlap(TreeTy *T, key_type_ref K, bool &Changed) {
|
||||||
if (!T)
|
if (!T)
|
||||||
return NULL;
|
return NULL;
|
||||||
Interval CurrentK = ImutInfo::KeyOfValue(Value(T));
|
Interval CurrentK = ImutInfo::KeyOfValue(Value(T));
|
||||||
|
|
||||||
// If current key does not overlap the inserted key.
|
// If current key does not overlap the inserted key.
|
||||||
if (CurrentK.getStart() > K.getEnd())
|
if (CurrentK.getStart() > K.getEnd())
|
||||||
return RemoveOverlap(Left(T), K);
|
return Balance(RemoveOverlap(Left(T), K, Changed), Value(T), Right(T));
|
||||||
else if (CurrentK.getEnd() < K.getStart())
|
else if (CurrentK.getEnd() < K.getStart())
|
||||||
return RemoveOverlap(Right(T), K);
|
return Balance(Left(T), Value(T), RemoveOverlap(Right(T), K, Changed));
|
||||||
|
|
||||||
// Current key overlaps with the inserted key.
|
// Current key overlaps with the inserted key.
|
||||||
// Remove the current key.
|
// Remove the current key.
|
||||||
|
Changed = true;
|
||||||
TreeTy *OldNode = T;
|
TreeTy *OldNode = T;
|
||||||
T = Remove_internal(CurrentK, T);
|
T = Remove_internal(CurrentK, T);
|
||||||
// Add back the unoverlapped part of the current key.
|
// Add back the unoverlapped part of the current key.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user