weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.27k stars 253 forks source link

Memoize the key of instance_variable_set #411

Open ooooooo-q opened 2 years ago

ooooooo-q commented 2 years ago

I used memory_profiler to check where rubyXL was using a lot of memory, and fixed it.

"@#{v[:accessor]}" generates two String objects, which can be expensive depending on the access frequency, so we memoized it.

Result

rubyXL 3.4.20 (with Ruby 3.1.0)

memoize "@#{v[:accessor]}"