[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: if-else
- From: Vaughan McAlley <ockegheim@...>
- Date: Thu, 15 Apr 2010 23:34:02 +1000
On 14 April 2010 00:41, Francisco <xxleite@gmail.com> wrote:
> very compact!
> x=(vXSTX>vXSX or vXSTX>vXSY) and vXSX+vXSTX or vXSX
This produces the following byte-code:
13 [5] GETGLOBAL 0 -1 ; vXSTX
14 [5] GETGLOBAL 1 -4 ; vXSX
15 [5] LT 1 1 0
16 [5] JMP 4 ; to 21
17 [5] GETGLOBAL 0 -1 ; vXSTX
18 [5] GETGLOBAL 1 -5 ; vXSY
19 [5] LT 0 1 0
20 [5] JMP 5 ; to 26
21 [5] GETGLOBAL 0 -4 ; vXSX
22 [5] GETGLOBAL 1 -1 ; vXSTX
23 [5] ADD 0 0 1
24 [5] TEST 0 0 1
25 [5] JMP 1 ; to 27
26 [5] GETGLOBAL 0 -4 ; vXSX
27 [5] SETGLOBAL 0 -6 ; x
...whereas the more readable:
x = vXSX
if (vXSTX > vXSX) or (vXSTX > vXSY) then
x = x + vXSTX
end
...produces
13 [6] GETGLOBAL 0 -4 ; vXSX
14 [6] SETGLOBAL 0 -6 ; x
15 [7] GETGLOBAL 0 -1 ; vXSTX
16 [7] GETGLOBAL 1 -4 ; vXSX
17 [7] LT 1 1 0
18 [7] JMP 4 ; to 23
19 [7] GETGLOBAL 0 -1 ; vXSTX
20 [7] GETGLOBAL 1 -5 ; vXSY
21 [7] LT 0 1 0
22 [7] JMP 4 ; to 27
23 [8] GETGLOBAL 0 -6 ; x
24 [8] GETGLOBAL 1 -1 ; vXSTX
25 [8] ADD 0 0 1
26 [8] SETGLOBAL 0 -6 ; x
... which makes it marginally more compact in terms of byte code
(though the variable names are the least readable I’ve seen in a
while!)
Vaughan