nom
nom copied to clipboard
length_count: use Vec::with_capacity
This change avoids reallocation while filling in the array. In my case this causes a ~20% perf increase.
This might cause regressions if some users rely on nom not allocating the whole array before an error happens, causing their parsers to change behavior from "starts parsing, encounters an error, backtracks to a previous alt/opt/whatever" to "starts parsing, causes an OOM abort". I don't think nom provides any guarantees in either direction.