json icon indicating copy to clipboard operation
json copied to clipboard

Stream cleanup

Open grisumbras opened this issue 3 years ago • 8 comments

Fix #213

grisumbras avatar Apr 28 '21 10:04 grisumbras

Codecov Report

Merging #551 (c1a299a) into develop (aae1863) will decrease coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #551      +/-   ##
===========================================
- Coverage    99.10%   99.10%   -0.01%     
===========================================
  Files           67       67              
  Lines         6058     6040      -18     
===========================================
- Hits          6004     5986      -18     
  Misses          54       54              
Impacted Files Coverage Δ
include/boost/json/basic_parser.hpp 100.00% <ø> (ø)
include/boost/json/detail/stream.hpp 100.00% <ø> (ø)
include/boost/json/serializer.hpp 100.00% <ø> (ø)
include/boost/json/impl/serializer.ipp 96.92% <100.00%> (-0.06%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aae1863...c1a299a. Read the comment docs.

codecov[bot] avatar Apr 28 '21 11:04 codecov[bot]

These affect performance

vinniefalco avatar Apr 28 '21 15:04 vinniefalco

Yeah, I see that. Do you know the reason? The changes should have been purely cosmetical?

grisumbras avatar Apr 28 '21 20:04 grisumbras

The changes should have been purely cosmetical?

The local stream allows the compiler to assume there is no aliasing

vinniefalco avatar Apr 28 '21 20:04 vinniefalco

@sdkrystian knows more

vinniefalco avatar Apr 28 '21 20:04 vinniefalco

@grisumbras @vinniefalco is correct -- creating the local streams allows for the compiler to assume no aliasing. Without them, it must operate under the assumption that the referenced stream may be modified by writes through aliasable pointer types within the function (or ones deeper within the call stack).

sdkrystian avatar May 01 '21 16:05 sdkrystian

In retrospect maybe we should have left a comment on the declaration for local_stream explaining intent.

vinniefalco avatar May 01 '21 16:05 vinniefalco