deltarho[1859] wrote:your code has little, if any use, in practice.
I was curious if there was any difference between these two ways to open a file and get a pointer to its content:
Code: Select all
Dim as long flen=Lof(f)
#define version 0
#if version
Dim as ubyte ptr pContent = Allocate(Lof(f)), CurPos=pContent, CrPos
Get #f, 1, *pContent, Lof(f)
#else
Dim as string content=Input(flen, #f)
Dim as ubyte ptr pContent = StrPtr(content), CurPos=pContent, CrPos
#endif
Close #f
....
#if version
DeAllocate(pContent)
#else
content="" ' release the input string
#endif
It turns out the lower one is 6 bytes shorter, and equally fast.
Code: Select all
pContent = @content[0]
pContent = StrPtr(content)
are absolutely equivalent, which is not surprising.
All art is quite useless.
<smile>
Exactly ;-)
FB developers are not as obsessed about code size as the demo scene or assembler programmers in general. I code my libraries with code size in mind but I don't exaggerate. If there are two equivalent ways to perform a task, I pick the shorter one because the longer one may pollute the instruction cache; if, however, the longer one is faster and is part of a significant loop, it will be chosen.