David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class DesignWrong. The answer to my question is yes. SubItems: TList<TSubItem> When you access the items, a function getter is called, and that's where the copy comes from. That function getter has to assign its result somewhere and the compiler makes a temporary local variable for it. Hence the record init etc. Access the array directly and there will be no copy. aItem.SubItems.List[i] The const arg works as you expect.
Mike Torrettinni replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class DesignYou are right! If I do this: If CheckSubItem(aItem.SubItems.List[i]) then there is no Initialize/FinalizeRecord anymore. Such a hidden little detail, important detail 🙂
Darian Miller replied to Rollo62's topic in Algorithms, Data Structures and Class DesignYou seem highly concerned about performance implications - so measure the performance. Simulate a million (or whatever constitutes a significant amount) receipts of randomized sample data and measure your few possible implementations. If you find very little difference, then pick the one that is easiest for your team to extend and maintain. If your original source is TBytes, and perhaps your output source is TBytes, then introducing any conversions seems wasteful, but gut feelings should only act as a general guide. You either measure or you keep guessing. If you keep guessing, you may accidently determine if it's (currently) providing acceptable performance.