Mercurial > repos > rhope
diff pattern.rhope @ 153:d86df83402f3
Small performance optimization in string lib
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 21 Dec 2010 04:11:29 +0000 |
parents | a7add4db4a25 |
children | ed70399a07aa |
line wrap: on
line diff
--- a/pattern.rhope Sun Dec 05 18:04:54 2010 -0500 +++ b/pattern.rhope Tue Dec 21 04:11:29 2010 +0000 @@ -100,16 +100,17 @@ Match@Pattern[pattern,string:num,no match,idx] { - num,no match,idx <- [pattern]_Match[string,0] + num,no match,idx <- [pattern]_Match[string,0,[string]Byte[0]] } -_Match@Pattern[pattern,string,n:num,no match,idx] +_Match@Pattern[pattern,string,n,b:num,no match,idx] { - b <- [string]Byte[n] myb <- [pattern]Byte >> If[[b]=[myb]] { - num, ,idx <- [[pattern]Straight >>]_Match[string, [n]+[1]] { } + ,check terminal <- [string]Byte[[n]+[1]] + { num,check terminal,idx <- [[pattern]Straight >>]_Match[string, [n]+[1], ~] } + Val[check terminal] { ,no match <- If[[pattern]Terminal? >>] { @@ -121,10 +122,11 @@ }{ If[[b]<[myb]] { - num, no match, idx <- [[pattern]Left >>]_Match[string, n] + num, no match, idx <- [[pattern]Left >>]_Match[string, n,b] }{ - num, no match, idx <- [[pattern]Right >>]_Match[string, n] + num, no match, idx <- [[pattern]Right >>]_Match[string, n,b] } } } +