deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

refactor(yaml): cleanup `stringifyFlowMapping()`

Open timreichen opened this issue 1 year ago • 2 comments

timreichen avatar Aug 20 '24 09:08 timreichen

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.25%. Comparing base (c817a5a) to head (eaa0ba9). Report is 11 commits behind head on main.

Files Patch % Lines
yaml/_dumper_state.ts 75.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5743      +/-   ##
==========================================
+ Coverage   96.23%   96.25%   +0.01%     
==========================================
  Files         480      480              
  Lines       38748    38736      -12     
  Branches     5616     5614       -2     
==========================================
- Hits        37291    37285       -6     
+ Misses       1416     1410       -6     
  Partials       41       41              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 20 '24 09:08 codecov[bot]

Frankly, I don't really see the purpose behind this PR.

There are several (tiny) performance benefits:

  • quote and separator are take out of the loop, therefore only need one check
  • stringifyNode()for key and value is called at the beginning of the loop, thus continues the loop before pairBuffer is even initialized.
  • there is no index !== 0 check, because the values are joined afterwards

It also is more readable imo and half the lines.

timreichen avatar Aug 22 '24 08:08 timreichen