Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use replace instead of substr
Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
Jimmy Zhuo authored and moritz committed May 11, 2010
1 parent 75b3762 commit d47ce57
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/builtins/Str.pir
Expand Up @@ -155,11 +155,7 @@ Increment and Decrement Methods
dec_2:
dec ipos
repl = substr RANGES, ipos, 1
$S0 = substr str, 0, r1
$I0 = r1 + 1
$S1 = substr str, $I0
str = concat $S0, repl
str = concat str, $S1
str = replace str, r1, 1, repl
# if the replacement wasn't a carry, we're done
if orig > repl goto done
carry:
Expand Down Expand Up @@ -190,11 +186,7 @@ Increment and Decrement Methods
inc ipos
.local string repl
repl = substr RANGES, ipos, 1
$S0 = substr str, 0, r1
$I0 = r1 + 1
$S1 = substr str, $I0
str = concat $S0, repl
str = concat str, $S1
str = replace str, r1, 1, repl
# if the replacement wasn't a carry, we're done
if orig < repl goto done
carry:
Expand All @@ -206,11 +198,7 @@ Increment and Decrement Methods
unless repl == '0' goto extend_1
repl = '1'
extend_1:
$S0 = substr str, 0, r0
$S1 = substr str, r0
str = concat $S0, repl
str = concat str, $S1

str = replace str, r0, 0, repl
done:
.return (str)
.end
Expand Down

0 comments on commit d47ce57

Please sign in to comment.