From: handa Date: Wed, 22 Apr 2009 08:07:05 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df8fc52d293cac1452df4ccd7bfaa4f5d745e86a;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MText.cs b/MText.cs index 50b573c..cdb6ad3 100644 --- a/MText.cs +++ b/MText.cs @@ -1229,15 +1229,12 @@ namespace M17N.Core if (from < root.From) { MInterval prev = root.Prev; - int deleting = root.From - from; - int deleted = 0; - while (deleted < deleting) + while (true) { int len = prev.Length - prev.LeftLength; M17N.DebugPrint ("merging "); prev.DumpOne (false, true); - deleted += len; if (prev.Left != null) { prev.Left.Parent = prev.Parent; @@ -1245,33 +1242,32 @@ namespace M17N.Core prev.Parent.Right = prev.Left; else prev.Parent.Left = prev.Left; + for (MInterval i = prev.Parent; i != root; i = i.Parent) + i.Length -= len; + if (prev == head) + break; prev = prev.Left.RightMost; } else { + prev.Parent.Right = null; + for (MInterval i = prev.Parent; i != root; i = i.Parent) + i.Length -= len; + if (prev == head) + break; prev = prev.Parent; - prev.Right = null; - prev.Length -= deleted; } } - while (prev.Parent != root) - { - prev.Length -= deleted; - prev = prev.Parent; - } } if (root.To < to) { MInterval next = root.Next; - int deleting = root.To - to; - int deleted = 0; - while (deleted < deleting) + while (true) { int len = next.Length - next.RightLength; M17N.DebugPrint ("merging "); next.DumpOne (false, true); - deleted += len; if (next.Right != null) { next.Right.Parent = next.Parent; @@ -1279,20 +1275,22 @@ namespace M17N.Core next.Parent.Left = next.Right; else next.Parent.Right = next.Right; + for (MInterval i = next.Parent; i != root; i = i.Parent) + i.Length -= len; + if (next == tail) + break; next = next.Right.LeftMost; } else { + next.Parent.Left = null; + for (MInterval i = next.Parent; i != root; i = i.Parent) + i.Length -= len; + if (next == tail) + break; next = next.Parent; - next.Left = null; - next.Length -= deleted; } } - while (next.Parent != root) - { - next.Length -= deleted; - next = next.Parent; - } } }