Zum Inhalt springen

Expensive Object In Loop (ARCH9072)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key swift.performance.expensive-object-in-loop · Severity warning · Category performance

Flags DateFormatter, NumberFormatter, JSONDecoder / JSONEncoder, ISO8601DateFormatter constructed inside a loop body.

for r in rows { let f = DateFormatter(); f.string(from: r.at) }
let f = DateFormatter()
for r in rows { f.string(from: r.at) }

Create the formatter / decoder once outside the loop and reuse it.