mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Minor string comparision optimizations (#77)
This commit is contained in:
parent
1013c21359
commit
6d0b5d92c2
@ -111,8 +111,7 @@ export class String {
|
||||
@operator("==")
|
||||
private static __eq(left: String, right: String): bool {
|
||||
if (left === right) return true;
|
||||
if (left === null) return right === null;
|
||||
if (right === null) return false;
|
||||
if (left === null || right === null) return false;
|
||||
|
||||
var leftLength = left.length;
|
||||
if (leftLength != right.length) return false;
|
||||
@ -150,8 +149,7 @@ export class String {
|
||||
@operator(">=")
|
||||
private static __gte(left: String, right: String): bool {
|
||||
if (left === right) return true;
|
||||
if (left === null) return right === null;
|
||||
if (right === null) return false;
|
||||
if (left === null || right === null) return false;
|
||||
|
||||
var leftLength = left.length;
|
||||
var rightLength = right.length;
|
||||
@ -188,8 +186,7 @@ export class String {
|
||||
@operator("<=")
|
||||
private static __lte(left: String, right: String): bool {
|
||||
if (left === right) return true;
|
||||
if (left === null) return right === null;
|
||||
if (right === null) return false;
|
||||
if (left === null || right === null) return false;
|
||||
|
||||
var leftLength = left.length;
|
||||
var rightLength = right.length;
|
||||
|
@ -140,7 +140,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 40)
|
||||
(i32.const 234)
|
||||
(i32.const 231)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -293,7 +293,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 40)
|
||||
(i32.const 234)
|
||||
(i32.const 231)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -5320,18 +5320,19 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
|
@ -10378,6 +10378,7 @@
|
||||
)
|
||||
(func $~lib/string/String.__eq (; 106 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
@ -10388,34 +10389,34 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
@ -10436,7 +10437,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
|
@ -161,7 +161,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 234)
|
||||
(i32.const 231)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -381,7 +381,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 213)
|
||||
(i32.const 210)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -1092,7 +1092,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 469)
|
||||
(i32.const 466)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3293,18 +3293,19 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
@ -3447,31 +3448,32 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
@ -3479,13 +3481,13 @@
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
@ -3503,11 +3505,11 @@
|
||||
)
|
||||
(i32.shl
|
||||
(select
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -3613,18 +3615,19 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
@ -3694,7 +3697,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 386)
|
||||
(i32.const 383)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3729,7 +3732,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 391)
|
||||
(i32.const 388)
|
||||
(i32.const 6)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -211,7 +211,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 234)
|
||||
(i32.const 231)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -469,7 +469,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 213)
|
||||
(i32.const 210)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -1271,7 +1271,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 469)
|
||||
(i32.const 466)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3770,6 +3770,7 @@
|
||||
)
|
||||
(func $~lib/string/String.__eq (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
@ -3780,34 +3781,34 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
@ -3828,7 +3829,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -3960,64 +3961,64 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
(select
|
||||
(tee_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(tee_local $5
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.lt_s
|
||||
(tee_local $5
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
@ -4157,64 +4158,64 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $2
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
(select
|
||||
(tee_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(tee_local $5
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.lt_s
|
||||
(tee_local $5
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
@ -4256,7 +4257,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 386)
|
||||
(i32.const 383)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
@ -4294,7 +4295,7 @@
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 391)
|
||||
(i32.const 388)
|
||||
(i32.const 6)
|
||||
)
|
||||
(unreachable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user