1. Use fprintf ("fast printf") instead of printf.
2. ++i is faster than both i++ and i = i + 1.
3. void main(void) is faster than int main(void) or int main(int, char **) since no value needs to be returned to the OS.
4. Swapping with exclusive-or (a^=b^=a^=b swaps a and b) is faster than using a temporary. This works for all types (including structures), but not on all compilers. Some compilers may also give you a harmless warning.
5. Static storage duration objects are faster than automatic storage duration objects because the CPU doesn't have to set aside storage on the stack every time a function is called. Make your loop indexes global so that you can use them everywhere: int i;
void func(void) { for (i = 0; i < 10; i++) ; /* ... */ }
void func2(void) { for (i = 0; i < 20; i++) ; /* ... */ }
/* ... */
6. Compilers often give more memory to arrays than you asked for. Here's how to check how big an array actually is (memset returns a null pointer if the size you passed to it is bigger than the size of the array you passed to it): int arr[256];
size_t realsize;
for (realsize = 0; realsize <= SIZE_MAX; ++realsize)
if (!memset(arr, 0, realsize)) break;
/* now you know that arr actually has realsize / sizeof (int) elements */
If you combine this with #5, your program will be faster in the long run (but this usually doesn't work for short programs).
Name:
Anonymous2008-10-05 21:11
4. Swapping with exclusive-or (a^=b^=a^=b swaps a and b) is faster than using a temporary. This works for all types (including structures), but not on all compilers. Some compilers may also give you a harmless warning.
my compiler optimizes away any operation that invokes undefined behavior.
I'm still REALLY busy, and so is 'ruhi and lolita. To the anon who mailed me a postcard... thanks?
Well, we started it and we're going to finish it, no matter how long it takes.
http://rechan.eu.org/misc/anoncoreutils/ http://rechan.eu.org/misc/anoncoreutils/STATUS
Halfway there. You know, if/when this does get completed it will be the first time anon actually finished something moderately large. So if you have the time and skill, don't miss out on your chance to be a part of this unique experiment in anonymous open-source development.
I should clean up rechan...
Name:
Anonymous2008-10-06 0:41
>>19
What about kernel you idiots? What about libc? Writing a lot of simple command line utilities is by no means something moderately large
I've been using Anonix for about two months, before this I was using Vista, but Vista SUUUUUUCKS!! When changing to Anonix, everything Just Works! Sure, I can't do anything, but what does work, really does work.
I don't think I've ever used an OS as user friendly as this!
I'll be looking forward to the highly optimized and easy to use kernel the Anonix Cabal will develop.
i am a cudder i ahev a PENIS and i host shitty imageboards w/ my REchan if you dont contribute on 10 coreutils i will fly into your room tonight and hax your anus
i am a hairy hardon. i ahev a long dick and i dive into vaginas. if you dont repost this comment on 10 other pages i will fly into your ass tonight and make a mess of your shit
yeah, spam that thread as well with your bots and revive it once in a while so you can post about part III. faggot
Name:
Anonymous2008-10-12 5:58
You have AWOKEN the anger of the MASTER PROGRAMMER.
Do you think that a FIRST YEAR could properly comprehend the subtle beauty of SICP? The ABELSON would be ashamed, if he were alive today. The MASTER PROGRAMMER is furrowing his brow at your insolence.
A lowly CO-OP engineering student like you is lucky to get by on the likes of THE LITTLE SCHEMER, much unlike the MASTER PROGRAMMER, which is me.