www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - invariant/const

1.Const doesn't nothing good to the optimization. It's only used as a tool  
to enforcing code and documentation.
In the scene of multithreading, your const version of something may  
changed by something else. You need to access the const enforced arg  
everytime. It should perform as fast as mutable version.

2.Invariant provides full possibility to optimize.

But what sort of optimization? It's pretty restricted. I can't think of  
one really boost the performance.

Rather say invariant boost performance, I would consider if it would slow  
down the mutable version for enforcing the multithreading issue. Accessing  
a mutable arg in a func always refers to real one. So your mutable version  
func would have good chance to slow down if it can potentially be  

So if you don't deal with multithreading, actually you don't touch D2?

使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Jul 03 2009