Welcome, Guest. Please login or register.
Amiga Kit Amiga Store Iridium Banner AMIStore App Store A1200/A600 4xIDE Interface

AuthorTopic: Help optimizing this...  (Read 752 times)

0 Members and 1 Guest are viewing this topic.

Offline Jose

Help optimizing this...
« on: May 10, 2005, 06:38:22 PM »
I have a linked list of structures wich, among other things, contain apointer to a function (a certain action). I also have an array of LONGs, each having flags that inicate actions that have been done. I’ll compare that with another array wich is similar but whose flags correspond to actions that must have been done before proceding. To make the comparison I’ll use an XOR. I never used C’s standard library but there must be some function that the compiler converts to the processor ‘s native XOR operation, or a way to do that. The result of the operation will of course be flags that correspond to actions that must still be done before proceding.
Is there a fast way to check the result of the XOR and procced to execute the corresponding functions, without having to check each bit at a time wich will be more time consuming?
My current idea, hopefully someone will come up with something faster, or more strightforward and efficient:

Make a table with 256 entries (all possible conbinations within a byte). Each entry in the table is a pointer to a NULL terminated array of numbers wich, when added to the number of the byte being checked (offset from the beginning of the array of LONGs) give the number of the linked list element whose function is to be executed (the linked list is organized in the as the corresponding flags in the LONG arrays).
All in all, checked bytes would be 8 times faster, but, discounting jumps to the table and  then to the array of numbers the table points to, then adding the byte nr. to each etc, should make it slower, say, 3 or times faster than individually checking bytes at best (just a bet).

I haven’t coded this yet, I’m still in the conceptual part trying to find the best algorithm before throwing time out coding something that will be scrapped later...

What do you think?
Maybe given that some functions have much more code compared to this, it's just not worth the hassle?
\\"We made Amiga, they {bleep}ed it up\\"

Offline SamuraiCrow

Re: Help optimizing this...
« Reply #1 on: May 11, 2005, 02:12:54 AM »
If you XOR all of the bits from one array to the other a one bit in the "actions performed" column that isn't specified in the "actions required" column you'll get a bit that is set in the destination which will indicate that the actions performed aren't sufficient to meet the needs of the actions required.  Have you excluded that possibility somewhere else in your code?

Offline Jose

Re: Help optimizing this...
« Reply #2 on: May 12, 2005, 07:16:09 PM »

well spotted thanks  :-o  I coded a sketch of this 2 days ago and I think I've made an AND (&) with the "actions required" after the XOR and before checking for TRUE flags but I'm not sure...
\\"We made Amiga, they {bleep}ed it up\\"