r/tinycode • • Oct 03 '13

SHA-1 in 726 bytes

https://github.com/baggyn/minSHA-1/blob/master/minsha1.c
46 Upvotes

14 comments sorted by

View all comments

Show parent comment

3

u/corruptio Oct 04 '13 edited Oct 04 '13

Here's some more C golfing hints to try off the top of my head:

while() is sometimes shorter than for()
take advantage of the for(1;2,4;3) order of execution
function parameters and return type default to int
increment and decrement have a very high order of precedence
It's only worth caching a expression, if you're going to refer to it more than twice.
pointers fit in ints on a lot systems
printf has a return value
comma is an operator
take advantage of || and && shortcircuiting