Passing array as const slows down code?
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Fri Apr 27 17:03:48 PDT 2012
On 28/04/12 00:29, Era Scarecrow wrote:
> Last try adding ref after const; At the off chance it's shallow copying, this
> should remove that.
Ahhh, that works. Thank you!
Back story: originally the reputation() function just took the array ratings and
made an internal copy, ratings_, which was used by the rest of the code. I took
that out in this commit:
https://github.com/WebDrake/Dregs/commit/4d2a8a055321c2981a453fc4d82fb781da2ea5c7
... because I found I got about a 2s speedup. It's exactly the speedup which
was removed by adding "const" to the function input, so I presume it's as you
say, that this was implicitly creating a local copy.
More information about the Digitalmars-d-learn
mailing list