Mercurial > repos > rhope
comparison 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 |
comparison
equal
deleted
inserted
replaced
152:e9a8269384bb | 153:d86df83402f3 |
---|---|
98 no match <- Yes | 98 no match <- Yes |
99 } | 99 } |
100 | 100 |
101 Match@Pattern[pattern,string:num,no match,idx] | 101 Match@Pattern[pattern,string:num,no match,idx] |
102 { | 102 { |
103 num,no match,idx <- [pattern]_Match[string,0] | 103 num,no match,idx <- [pattern]_Match[string,0,[string]Byte[0]] |
104 } | 104 } |
105 | 105 |
106 _Match@Pattern[pattern,string,n:num,no match,idx] | 106 _Match@Pattern[pattern,string,n,b:num,no match,idx] |
107 { | 107 { |
108 b <- [string]Byte[n] | |
109 myb <- [pattern]Byte >> | 108 myb <- [pattern]Byte >> |
110 If[[b]=[myb]] | 109 If[[b]=[myb]] |
111 { | 110 { |
112 num, ,idx <- [[pattern]Straight >>]_Match[string, [n]+[1]] { } | 111 ,check terminal <- [string]Byte[[n]+[1]] |
112 { num,check terminal,idx <- [[pattern]Straight >>]_Match[string, [n]+[1], ~] } | |
113 Val[check terminal] | |
113 { | 114 { |
114 ,no match <- If[[pattern]Terminal? >>] | 115 ,no match <- If[[pattern]Terminal? >>] |
115 { | 116 { |
116 num <- [n]+[1] | 117 num <- [n]+[1] |
117 idx <- Index >>[pattern] | 118 idx <- Index >>[pattern] |
119 } | 120 } |
120 | 121 |
121 }{ | 122 }{ |
122 If[[b]<[myb]] | 123 If[[b]<[myb]] |
123 { | 124 { |
124 num, no match, idx <- [[pattern]Left >>]_Match[string, n] | 125 num, no match, idx <- [[pattern]Left >>]_Match[string, n,b] |
125 }{ | 126 }{ |
126 num, no match, idx <- [[pattern]Right >>]_Match[string, n] | 127 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b] |
127 } | 128 } |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
132 |