Post Reply 
What's wrong with your HEAD?
10-08-2018, 03:36 PM
Post: #10
RE: What's wrong with your HEAD?
(10-08-2018 10:06 AM)3298 Wrote:  Yes you could add something! ... well, to your list commands library.
...
If you want to be even more efficient, you could investigate how stable PTR 1933C is across ROM versions (or at least across the ROM versions you want to support), and possibly use that in place of the innermost embedded subprogram.

(10-08-2018 11:03 AM)Werner Wrote:  That's why, in my GX library for the SX, I implemented HEAD as
...

^ErrBadDim (FPTR 6 92) appears to be a supported flash pointer that performs the # 501 ERROROUT sequence, at least on the supported platforms for ListExt.

I certainly don't mind including a list-focused HEAD replacement in ListExt ('LHEAD' definitely follows the established naming convention Smile). Both of the above approaches are able to check for an empty list and isolate the first element fairly efficiently, and a preliminary check on an emulated system shows them to perform similarly. I'll follow that up with some tests on a real 50g when I get a moment, but I'd be surprised if there were any meaningful performance differences between the two approaches. 3298's is a couple of bytes smaller, so I'd lean in that direction if there's truly no performance difference on real hardware.

(10-08-2018 02:08 PM)pier4r Wrote:  In the listExt there should be already LPOP or LPOPR to have a sort of head behavior, isn't it?

The big difference with LPOP/R is that they leave the residual list elements on the stack. This means that they both have a need of traversing and copying the entire list in order to return the complete results, thus incurring the performance penalties both of those steps require. The main benefit of something like LHEAD is that it would only need to deal with the first element, and thus it can operate much faster than something that has to scan/rebuild the entire list. If you don't need the residual list elements, LHEAD would be significantly faster than LPOP NIP.

Nice discussion!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
What's wrong with your HEAD? - John Keith - 10-07-2018, 02:47 PM
RE: What's wrong with your HEAD? - 3298 - 10-07-2018, 08:55 PM
RE: What's wrong with your HEAD? - pier4r - 10-07-2018, 09:19 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 03:54 AM
RE: What's wrong with your HEAD? - 3298 - 10-08-2018, 10:06 AM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018 03:36 PM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 05:24 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 04:12 PM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 09:55 AM
RE: What's wrong with your HEAD? - Werner - 10-08-2018, 11:03 AM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 02:08 PM
RE: What's wrong with your HEAD? - 3298 - 10-08-2018, 05:55 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 07:47 PM
RE: What's wrong with your HEAD? - pier4r - 10-10-2018, 11:07 AM
RE: What's wrong with your HEAD? - DavidM - 10-10-2018, 02:56 PM
RE: What's wrong with your HEAD? - 3298 - 10-10-2018, 05:41 PM
RE: What's wrong with your HEAD? - DavidM - 10-19-2018, 01:52 AM
RE: What's wrong with your HEAD? - pier4r - 10-20-2018, 05:37 PM



User(s) browsing this thread: 1 Guest(s)