Refactor save size calculation with SaveSizeCounter
SaveSizeCounter is introduced and used for calculating the save size of objects. The previous method of calculating save size directly in each class was replaced with a call to the SaveSizeCounter's calc method. This results in a cleaner, more maintainable code as the size calculation logic is now centralized in one class. It is more efficient and scalable as any changes to the calculation can be made in one place and will be reflected everywhere.
This commit is contained in:
parent
a918c83ec1
commit
0cefb47b66
6 changed files with 30 additions and 15 deletions
|
|
@ -221,7 +221,7 @@ namespace obj {
|
|||
ndf << tp::String(in->type->name);
|
||||
|
||||
// allocate for object file header
|
||||
ndf.setFreeAddress(ndf.getFreeAddress() + sizeof(ObjectFileHead) + tp::String::Logic::calcLength(in->type->name) + sizeof(tp::String::Logic::Index));
|
||||
ndf.setFreeAddress(ndf.getFreeAddress() + sizeof(ObjectFileHead) + tp::SaveSizeCounter::calc(tp::String(in->type->name)));
|
||||
|
||||
// calc max size needed for saving all hierarchy of types
|
||||
tp::alni file_alloc_size = objsize_file_util(in, in->type);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue