[snip] > + unsigned long patternl = 0; > + grub_size_t i; > + > + for (i = 0; i < sizeof (unsigned long); i++) > + patternl |= ((unsigned long) pattern8) << (8 * i); > + >
might I suggest: unsigned long patternl = pattern8; patternl |= patternl << 8; patternl |= patternl << 16; patternl |= patternl << 32; patternl |= patternl << 64; O(lg N) instead of O(N), no loop, no branches, and the compiler should be smart enough to optimize away the last two lines on systems with narrower long.
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel