Use `std::forward()` in `ConvertToV8()`

chore: use `std::forward()` in `ConvertToV8()` (#31817)
Use `std::forward()` in `ConvertToV8()`choreuse std forward converttov8

Committed by RaisinTen

commit message
chore: use `std::forward()` in `ConvertToV8()` (#31817)

The variable `input` is accepted by a universal reference, so it doesn't
make sense to cast a potential lvalue reference into an rvalue
reference. In case `input` is an lvalue reference, we should rather
forward the value as is to `ToV8()`.
 
Signed-off-by: Darshan Sen <[email protected]>

Editor assessment

The subject precisely names the change: std::forward() is now used in ConvertToV8(). The body then teaches the actual C++ reasoning: the input parameter is a universal reference, so casting a potential lvalue to an rvalue reference is wrong, and lvalues should be forwarded as-is to ToV8(). That is a self-contained lesson in perfect forwarding, motivated and applied, not a restatement. The chore type is a fair framing for an internal correctness fix, the signed-off-by trailer is well-formed, and hygiene is clean throughout. An exemplary message: precise header, genuinely instructive body.

Browse categories

More chore examples · Back to search