Expensive Object In Loop (ARCH9072)
Esta página aún no está disponible en tu idioma.
Key swift.performance.expensive-object-in-loop · Severity warning · Category performance
Flags DateFormatter, NumberFormatter, JSONDecoder / JSONEncoder, ISO8601DateFormatter constructed inside a loop body.
Incorrect
Section titled “Incorrect”for r in rows { let f = DateFormatter(); f.string(from: r.at) }Correct
Section titled “Correct”let f = DateFormatter()for r in rows { f.string(from: r.at) }Create the formatter / decoder once outside the loop and reuse it.