Commit 09cddf5
authored
Simplify and optimize RemoveMagicPrefixLine.
If body has ")]}'\n" prefix, there's no need to use bytes.IndexByte to
find the first '\n' character, it's known to be at index 4 because
bytes.HasPrefix(body, []byte(")]}'\n")) was true.
Since this is called often, it's probably a good idea to factor out
[]byte(")]}'\n") into a package scope variable, instead of potentially
allocating once per RemoveMagicPrefixLine call.1 parent 978d5a3 commit 09cddf5
1 file changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 439 | + | |
| 440 | + | |
445 | 441 | | |
446 | 442 | | |
447 | 443 | | |
448 | 444 | | |
| 445 | + | |
| 446 | + | |
449 | 447 | | |
450 | 448 | | |
451 | 449 | | |
| |||
0 commit comments