~/bend-docscommunity

bolt/rules/suspicious/concat.bend fails

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/suspicious/concat.bend as Concat

rule concat: a def passes itself a parameter grown at the end, p ++ x or List.append(.., p, ys) (String.append(p, ..) too). A String and a List are cons lists, so appending copies all of p: the loop is quadratic, with right output (night-train's text step cost three times the render; rootagi's JSON stringify). Prepend (x <> acc) and reverse once at the end, build with h <> go(t), or gather pieces and join them once.

7 imports
import Base
import ../../src.bend as Src
import ../../finding.bend as F
import ../../../syntax/lex.bend as Lex
import ../../../syntax/tree.bend as Tree
import ../calls.bend as Calls
import ../../../lazy/lazy.bend as Lazy