Mercurial > repos > rhope
changeset 157:37b999dbd12e
Small change to make String Cat trees a little more balanced
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 23 Dec 2010 15:48:19 -0500 |
parents | ed70399a07aa |
children | 0e06f29aa83d |
files | string.rhope |
diffstat | 1 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/string.rhope Thu Dec 23 02:00:27 2010 +0000 +++ b/string.rhope Thu Dec 23 15:48:19 2010 -0500 @@ -828,26 +828,50 @@ } } +Depth@String[string:out] +{ + out <- 0 +} + +Depth@String Slice[string:out] +{ + out <- 0 +} + +Depth@String Cat[string:out] +{ + out <- Depth >>[string] +} + Blueprint String Cat { Left Right Length ByteLen + Depth } String Cat[left,right:out] { - out <- [[[[Build[String Cat()] + out <- [[[[[Build[String Cat()] ]Left <<[left] ]Right <<[right] ]Length <<[ [[left]Length]+[[right]Length] ] ]ByteLen <<[ [[left]Byte Length]+[[right]Byte Length] ] + ]Depth <<[ [1]+[Min[[left]Depth, [right]Depth]] ] } Append@String Cat[left,right:out] { - out <- String Cat[left,right] + ll <- [left]Left >> + lr <- [left]Right >> + If[[[ll]Depth] > [[lr]Depth]] + { + out <- String Cat[ll, String Cat[lr,right]] + }{ + out <- String Cat[left,right] + } } Byte@String Cat[string,index:out,invalid]