Commit 01e3190
src: general C++ cleanup in node_url.cc
- Merge `domain` and `opaque` storage in URL parser:
This just simplifies the code a bit, having multiple fields
in an union with the same type is usually just overhead.
- Add move variant of `URLHost::ToString()`:
This helps avoid unnecessary string copy operations, especially
since we control the lifetime of `URLHost` objects pretty well.
- Use const refs in node_url.cc where appropriate
- Remove or reduce overly generous `.reserve()` calls:
These would otherwise keep a lot of unused memory lying around.
- Return return values instead of unnecessary pointer arguments
- Use more common/expressive variable names
- Avoid macro use, reduce number of unnecessary JS strings:
There’s no reason for `GET`, `GET_AND_SET` and `UTF8STRING` to be
macros. Also, `GET` would previously create a JS string instance
for each single call, even though the strings it was called
with were compile-time constants.
- Avoid unnecessary JS casts when the type of a value is known
- Avoid (commonly unnecessary) copy for whitespace stripping
PR-URL: #19598
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>1 parent 9f20534 commit 01e3190
2 files changed
+192
-151
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
| |||
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| 248 | + | |
245 | 249 | | |
246 | 250 | | |
247 | 251 | | |
| |||
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| 258 | + | |
254 | 259 | | |
255 | 260 | | |
256 | 261 | | |
| |||
0 commit comments