-
Notifications
You must be signed in to change notification settings - Fork 212
Add back write caching. #4001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add back write caching. #4001
Conversation
PR Health |
6aad9d7
to
016caae
Compare
cf45807
to
7db501e
Compare
7db501e
to
bd9b012
Compare
Encoding encoding = utf8, | ||
required void Function() writer, | ||
}) { | ||
_stringContentCache[id] = contents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be some handling here of non-utf8 encoding? (I seem to recall a comment from some point about only saving utf8-encoded strings, also above we only read from _stringContentCache if using utf8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was incorrect; fixed and added test coverage.
Could you take another look, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Could you please take another look for the non-UTF-8 question? Now with test coverage, which I should have added in the first place.
Encoding encoding = utf8, | ||
required void Function() writer, | ||
}) { | ||
_stringContentCache[id] = contents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was incorrect; fixed and added test coverage.
Could you take another look, please?
if (encoding != utf8) { | ||
final bytes = readAsBytes(id, ifAbsent: ifAbsent); | ||
return encoding.decode(bytes); | ||
} | ||
|
||
// Check _stringContentCache first to use it as a cache for conversion of | ||
// Check `_stringContentCache` first to use it as a cache for conversion of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to put a comment at the right place, but line 223-235 could basically be replaced by a call like final bytes = readAsBytes(id, ifAbsent: ifAbsent);
(as above).
_stringContentCache[id] = contents; | ||
} else { | ||
_stringContentCache.remove(id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this stuff could (almost) be replaced by a call to writeAsBytes
.
Retry of #3995.
Switch to sync I/O landed already in #4000.
Differences to #3995:
_Write
classFix
copyWith
foronCanReadController
in the test ReaderWriter, as this now matters for one test.