|
|
|
|
|
by Mawr
329 days ago
|
|
If I understood the problem correctly, you should try calculating each format of the data once and reusing it. Something like: type ID {
AsString string
AsInt int
AsWhatever whatever
}
function new type ID:
return new ID {
AsString: calculateAsString()
AsInt: calculateAsInt()
AsWhatever: calculateAsWhatever()
}
This does assume every representation will always be used, but if that's not the case it's a matter of using some manner of a generic only-once executor, like Go's sync.Once. |
|
I agree that would be a good solution, despite that my data is huge, but it assumes the data doesn't change, or doesn't change that much.