fs: accept all valid utf8 values in fast paths#64341
Conversation
2380daa to
bfaade2
Compare
bfaade2 to
1d3f916
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64341 +/- ##
==========================================
- Coverage 90.24% 90.23% -0.02%
==========================================
Files 741 741
Lines 240976 240982 +6
Branches 45408 45401 -7
==========================================
- Hits 217477 217448 -29
- Misses 15070 15120 +50
+ Partials 8429 8414 -15
🚀 New features to boost your workflow:
|
|
I don't think we should land this. The more checks we have, the more performance impact it would create. Do you have any examples out there that is impacted by this? Does people really pass UTF8? If not, let's close this. |
|
Hi @anonrig thanks for the review! I completely understand the concern regarding the performance impact on the fast path. I picked this up to resolve issue #49888, as there seemed to be some inconsistency in how variations like That said, if the consensus is that the branch/check overhead for the 99% of users passing standard |
Fixes: #49888
This PR introduces a lightweight
isUtf8Encodinghelper to ensurefs.readFileSync,fs.writeFileSync, andencodeRealpathResultuse the fast C++ path for all valid variations of the utf8 encoding string (utf8,utf-8,UTF8,UTF-8).