def message

bend-lint-rules@0.2.0.0 · performance/template_value_field.bend:26

import bend-lint-rules@0.2.0.0/performance/template_value_field.bend as TemplateValueField
import Base

26# Functions
27# =========
28def message(+template: String, owner: String) -> String:
29  template
30    ++ " is a template, so reading it here builds its whole record, closures too, to read a part of it; and a record of functions passed as a template is built again at each use, so "
31    ++ owner
32    ++ " repeats this wherever its record is used, twice as often at each level of nesting. All lanes. Measured on a combinator nested 6 deep: 1.7 s against 1.0 s after the fix on the C lane, 49 s against 14 s on the JS lane; on a nested model, 6% of the time. Confidence: medium, as the fix moves the work to each read of the field. Make the field a function of Unit (`n: Unit -> U32`, built as `u => ..`), so that "
33    ++ template
34    ++ " is read only when the field is called. If the field is read about as often as the record is built, expect this finding."

Uses (2)

Used by (1)