(9 hours ago)DSMan195276 Wrote:(06-04-2025, 07:31 PM)madscijr Wrote: My question is, can't we update the compiler to be a little smarter, and generate code that uses these direct memory manipulation tricks, for commands like array(index)?
If you need to move large parts of an array though then `_Mem` is faster, `_MemCopy` uses faster techniques than just doing a loop. In theory the compiler could do optimizations like that, but determining whether a loop in the code can be replaced is complicated and in many cases not possible.
Thanks. That makes sense.
So how about they add a new native QB64PE command called MoveArrayElements(MyArray, SourceStartElementIndex, SourceEndElementIndex, DestIndex) that uses the memory method under the hood? Then the compiler does not need to try and determime what the source code is doing, it's now just a straightforward command.
(Or, I suppose we could create a user-defined function that does the same, with whatever checks to make sure the values are valid. Either way, in the spirt of BASIC, to keep life simple and save the programmer from having to worry about low level headaches like worrying about how many bytes a variable uses, etc. If we don't mind that low-level stuff, we might as well be coding in C!)