문제

I should expose some of my class data, but it is expected to work in very productivity demanding area, so naturally I wonder, what is the best way to do so: keep to design principles and make this exposition via properties, or to forget about it and just make my data public?

도움이 되었습니까?

해결책

A property is a function call, but it is generally a trivial one that can be inlined.... at least as long as it is final and you use the right compiler setup (gdc -O or ldc's optimization. a quick test is showing me that dmd -inline does not inline it though!).

So right now, if you are using gdc or ldc, a final property is free because it will be inlined and optimized. A virtual property function I'm not sure about. If you are using dmd, there's a small cost of a function call, so if it is a tight loop, you'll probably get a speedup with a public field.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top