Passing array as const slows down code?

Jonathan M Davis jmdavisProg at gmx.com
Fri Apr 27 10:23:46 PDT 2012


On Friday, April 27, 2012 11:18:26 Steven Schveighoffer wrote:
> const should not affect code generation *at all*, except for name mangling
> (const MyStruct is a different type from MyStruct), and generating an
> extra TypeInfo for const MyStruct and const MyStruct[]. Const is purely a
> compile-time concept.

Thanks to the fact that const is transitive and that it's illegal to cast it 
away to use mutation, const _can_ affect code optimizations, but I don't know 
exactly under what circumstances it does in the current compiler.

Still, like you, if anything, I'd expect const to be faster rather than slower 
if there's any speed difference. So, what's happening is a bit weird, and I 
have no idea what's going on.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list