GCC C++ “Hello World” program -> .exe is 500kb big when compiled on Windows. How can I reduce its size?

The problem here is not so much with the library as it is with the way the library is linked. Granted, iostream is a moderately huge library but I don’t think it can be so huge as to cause a program to generate an executable that is 900KB larger than a similar one that uses … Read more

Packing arbitrary triangles into a finite box?

“tight as reasonable” -> Something working is better than nothing. These code fragments provide a simple solution to stuff shapes (also triangles) band by band into a rectangle. public abstract class Shape { protected Point offset = new Point(); public abstract int getHeight(); public abstract int getWidth(); } public class Triangle extends Shape { // … Read more

Fastest way to sort 32bit signed integer arrays in JavaScript?

I’ve tested typed arrays, the QSIP version seems to be good in modern browsers: 2 000 000 elements QSIP_TYPED | RDXIP_TYPED | QSIP_STD | RDXIP_STD ———————————————————- Chrome | 300 1000 600 1300 Firefox | 550 1500 800 1600 http://jsfiddle.net/u8t2a/35/ Support (source: http://caniuse.com/typedarrays): IE 10+ | FF 4+ | Chrome 7+ | Safari 5.1+ | Opera … Read more

Haskell: how to detect “lazy memory leaks”

The main method for detecting memory leaks is heap profiling. Specifically, you’re looking for unexpected growth in the amount of resident (mostly heap) memory, either the maximum residency in the +RTS -s statistics output, or — more reliably — a characteristic “pyramid” shape over time in heap profile output generated with the +RTS -h<x> flags … Read more

How would you make this switch statement as fast as possible?

Assuming every input will be a valid ActivCode, that you can change the enumeration values and highly coupled to the GetHashCode implementation: enum MarketDataExchange { NONE, NBBO = 371857150, AMEX = 372029405, BSE = 372029408, BATS = -1850320644, NSE = 372029407, CHX = -284236702, NYSE = 372029412, ARCA = -734575383, NASDAQ = 372029421, NASDAQ_ADF = … Read more