Skip to content

Commit 6cded0a

Browse files
committed
optimize str(r)str
1 parent 2229d84 commit 6cded0a

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/libc/strrstr.src

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ _strrstr:
1717
ld bc, 0
1818
cpir
1919
sbc hl, hl
20-
dec hl
21-
sbc hl, bc ; carry will be cleared
20+
scf
21+
sbc hl, bc ; carry will be set
2222
ex (sp), hl ; strlen(needle)
2323
push hl ; needle
2424

2525
ex de, hl
2626
push hl
27-
ld bc, 0
27+
ld bc, -1
2828
cpir
2929
sbc hl, hl
30-
dec hl
3130
sbc hl, bc
3231
ex (sp), hl ; strlen(haystack)
3332
push hl ; haystack

src/libc/strstr.src

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ _strstr:
2424
ld bc, 0
2525
cpir
2626
sbc hl, hl
27-
dec hl
28-
sbc hl, bc ; carry will be cleared
27+
scf
28+
sbc hl, bc ; carry will be set
2929
ex (sp), hl ; strlen(needle)
3030
push hl ; needle
3131

3232
ex de, hl
3333
push hl
34-
ld bc, 0
34+
ld bc, -1
3535
cpir
3636
sbc hl, hl
37-
dec hl
3837
sbc hl, bc
3938
ex (sp), hl ; strlen(haystack)
4039
push hl ; haystack

0 commit comments

Comments
 (0)