strip_attributes icon indicating copy to clipboard operation
strip_attributes copied to clipboard

Use frozen string literals and regex constants to reduce allocations

Open maxfierke opened this issue 2 years ago • 0 comments

When doing operations on lots of models, strip_attributes can be responsible for a lot of small allocations for strings and regexes that do not change, but are nonetheless re-allocated every time a model is saved. Across thousands of records, this is a sizeable chunk of memory. Luckily, since the strings and regexes do not change, we can mark them as frozen and/or reference them via constants to avoid allocating them more than once.

maxfierke avatar May 24 '22 15:05 maxfierke