-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
FilePathLayout - Reduce memory-allocation for cleanup of filename #1745
Conversation
Current coverage is 80% (diff: 96%)@@ master #1745 diff @@
==========================================
Files 274 274
Lines 17066 17079 +13
Methods 2698 2699 +1
Messages 0 0
Branches 1910 1912 +2
==========================================
+ Hits 13686 13711 +25
- Misses 2931 2932 +1
+ Partials 449 436 -13
|
9f307d9
to
2a4aa22
Compare
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.
Added two small notes
@@ -77,6 +77,9 @@ internal class FilePathLayout : IRenderable | |||
|
|||
private bool _cleanupInvalidChars; | |||
|
|||
private string _cachedPrevRawFileName; | |||
private string _cachedPrevCleanFileName; |
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.
We should document (xmldoc) that _cachedPrevCleanFileName
is a pair with _cachedPrevRawFileName
, right?
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 they are working together. Will update the xml-doc
if ((!_cleanupInvalidChars || cleanedFixedResult != null) && _filePathKind == FilePathKind.Absolute) | ||
return rawFileName; // Skip clean filename string-allocation | ||
|
||
if (string.CompareOrdinal(_cachedPrevRawFileName, rawFileName) == 0 && _cachedPrevCleanFileName != null) |
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.
In case of performance, the check _cachedPrevCleanFileName != null
should be on the left?
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.
_cachedPrevCleanFileName will never be null, and when it is then _cachedPrevRawFileName is also null. I just have a secret agenda when it comes to the PR with PoolSetup :)
…le (Reuse clean-filename when raw-filename is unchanged)
2a4aa22
to
acc8071
Compare
Reviewed 1 of 1 files at r2. Comments from Reviewable |
Thanks again! |
Reuse clean-filename when raw-filename is unchanged.
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)