Commit 0bb8417
committed
[cpp] Optimise Bytes.ofString utf8
To use the current Utf8.encode method, we have to run getByteCount which
iterates through the string to create a buffer which is the right size.
However, since Utf8.encode is a public function, it has to validate that
the size of the buffer is correct, which means it iterates through the
string again.
This new Utf8.encode method without a buffer argument creates its own
array and returns it, avoiding the unnecessary check.1 parent 8148309 commit 0bb8417
2 files changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 256 | + | |
264 | 257 | | |
265 | 258 | | |
266 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| |||
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | | - | |
| 77 | + | |
0 commit comments