Welcome, Guest. Please login or register.

Author Topic: Help optimizing this...  (Read 948 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show all replies
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 JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show all replies
Re: Help optimizing this...
« Reply #1 on: May 12, 2005, 07:16:09 PM »
@samurai

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\\"