Skip to content

Consider minimising copying of runner data #28

@tturocy

Description

@tturocy

From 6f0f040 the implementation of tracking runner data has been reorganised, with a separate data structure collecting the data by base.

At present a lot of copying is done:

  • Copying of the IDs of runner, pitcher, and catcher into the structure;
  • Copying of data between bases (instead of manipulation).

In principle, it should be possible instead for the game state to use pointers to refer back to strings allocated in the original game, rather than allocating strings and copying them, as the game state only makes sense in reference to a game, and it would be an error to deallocate a game and then use a game state after the game has been deallocated.

This would also involve needing to change lineups from copying to pointer manipulation as well.

This should be straightforward to accomplish, but will require some testing to be careful of memory management. It would also have as a side effect the benefit of removing the fixed-width buffers (of 50 characters) for baserunner/pitcher/catcher IDs, which is one of the few places there's any sort of fixed-width restriction in the codebase.

This might also have some performance benefits, as it would eliminate a fair amount of copying as well as in some places allocation/deallocation, although the library is fast enough as is that the benefits of being slightly faster ought to be marginal. So this is very much a rainy-day sort of project.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions