I try to express a think shared by several people.
Some function call could be removed by their value.
For example:
RGB(255,0,0) is equivalent in #FF0000
Even if RGB() is a function, given x,y,z (means x,y and z are constants) RGB(x,y,z) is a given value too.
So, a possible optimisation could be removing a function call by its value according to:
- the entries are constants
- the value retrieved by the function is a constant too.
Some function call could be removed by their value
Re: Some function call could be removed by their value
I don't know what you mean? But when the compiler sees RGB(255,0,0) in
your source, it's replaced by #FF0000 in the executable; in other words,
putting RGB(255,0,0) in your code is the same as putting a constant in
your code with the value #FF0000.
your source, it's replaced by #FF0000 in the executable; in other words,
putting RGB(255,0,0) in your code is the same as putting a constant in
your code with the value #FF0000.
Sure?

Code: Select all
; a = RGB(255,0,0)
PUSH dword 0
PUSH dword 0
MOV eax,255
CALL PB_RGB
MOV dword [v_a],eax
Dräc
- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
That's if you do something like
Then it will generate the string in the executable rather than have to perform string concatenation.
Similarly, by itself will create an "A" in your executable so there is no call to a Chr() function and b will take a copy of the string from your exe.
Code: Select all
b.s = "Foo"+Chr(65)+"wibble"
Similarly,
Code: Select all
b.s = Chr(65)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
PB:
That is correct, but it only applies to the Chr() function because this is very
frequently used with constant values as input.
Dräc:
Just overwrite the PB function with a macro...
That is correct, but it only applies to the Chr() function because this is very
frequently used with constant values as input.
Dräc:
Just overwrite the PB function with a macro...
Code: Select all
Macro RGB(r, g, b)
(((b) << 16) | ((g) << 8) | (r))
EndMacro
; a = RGB(255,0,0)
MOV dword [v_a],255
quidquid Latine dictum sit altum videtur