browsermt / mts

Marian Translation Service
Apache License 2.0
18 stars 4 forks source link

Prefer to reuse complex objects in loops #20

Closed kpu closed 3 years ago

kpu commented 3 years ago

If you've got an object that entails a memory allocation or other expensive construction/destruction, prefer to reuse it by pulling the object outside a loop. I see Timer, Histories and PCItem

https://github.com/browsermt/mts/blob/338d5f76bce2c970c9f2b3c240b13b35ef4f733c/src/bergamot/batch_translator.cpp#L117-L136

jerinphilip commented 3 years ago

https://github.com/browsermt/mts/blob/c46eee7190b6768abe583a5a84be6f468a8ccb43/src/bergamot/batch_translator.cpp#L104-L121

Closing.