writer_base::flush_to_file should always clear buffers#240
Merged
Conversation
Existing behavior clears buffers only if the existing file
is different from the buffer contents. Should clear
unconditionally to permit deterministic behavior.
Test:
struct writer : xlang::text::writer_base<writer> { } w;
w.write("hi");
w.flush_to_file("one");
w.flush_to_file("two");
Run this program twice.
Old behavior: The first time you run it, "one" contains "hi"
and "two" is empty. The second time you run it, "one"
contains 'hi" and "two" also contains "hi". Contents of
file "two" depends on factors not under app's control.
New behavior: Regardless of status of existing files "one"
and "two", "one" always contains "hi" and "two" is always
empty.
DefaultRyan
approved these changes
Mar 22, 2019
kennykerr
approved these changes
Mar 22, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Existing behavior clears buffers only if the existing file is different from the buffer contents. Should clear
unconditionally to permit deterministic behavior.
Test:
Run this program twice.
Old behavior: The first time you run it, "one" contains "hi" and "two" is empty. The second time you run it, "one" contains 'hi" and "two" also contains "hi". Contents of file "two" depends on factors not under app's control.
New behavior: Regardless of status of existing files "one" and "two", "one" always contains "hi" and "two" is always empty.