On 01-Jul-2015 00:14, H. S. Teoh via Digitalmars-d wrote:
While investigating:https://issues.dlang.org/show_bug.cgi?id=4244 I found that the druntime function for computing the hash of static arrays (this also applies to dynamic arrays, btw) is horrendously slow: about 8-9 times slower than the equivalent operation on a POD struct of the same size. The problem is caused by the call to hasCustomToHash() inside getArrayHash() in object.d, which in turn calls getElement(), which walks the typeinfo tree to find the TypeInfo for the first non-array / typedef type info definition, in order to determine if array elements have a custom toHash method. This walk is done *every single time* the array is hashed, even though the return value never changes for each array type.
Can't the compiler just help us and populate a variable in TypeInfo that is hasCustomToHash is inefficiently computing?
-- Dmitry Olshansky
