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
Optimize Evaluate #5676
Optimize Evaluate #5676
Changes from 4 commits
8b59434
07a77e0
1e1939c
4b42650
a008a27
2d239b1
f476616
05272f8
57e230f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -738,11 +738,6 @@ internal static string ExpandMetadataLeaveEscaped(string expression, IMetadataTa | |
return expression; | ||
} | ||
|
||
if (expression.Length == 0) | ||
{ | ||
return expression; | ||
} | ||
|
||
ErrorUtilities.VerifyThrow(metadata != null, "Cannot expand metadata without providing metadata"); | ||
|
||
// PERF NOTE: Regex matching is expensive, so if the string doesn't contain any item metadata references, just bail | ||
|
@@ -1938,7 +1933,7 @@ private static class ItemExpander | |
internal static string ExpandItemVectorsIntoString<T>(Expander<P, I> expander, string expression, IItemProvider<T> items, ExpanderOptions options, IElementLocation elementLocation) | ||
where T : class, IItem | ||
{ | ||
if (((options & ExpanderOptions.ExpandItems) == 0) || (expression.Length == 0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure this condition was not helping? FWIW, the caller is not performing this check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The caller checks the length before it expands metadata and properties. If it's just a property or just metadata, and it happens to be empty, there could be an extra string before this, but I think that's the only case. Still valid, so I added it back. |
||
if ((options & ExpanderOptions.ExpandItems) == 0 || expression.Length == 0) | ||
{ | ||
return expression; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,7 +308,7 @@ public override string UnevaluatedValue | |
|
||
public override bool IsImported => Link.IsImported; | ||
|
||
internal override string EvaluatedValueEscapedIntenral => Link.EvaluatedIncludeEscaped; | ||
internal override string EvaluatedValueEscapedInternal => Link.EvaluatedIncludeEscaped; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this was in its own commit it'd be a lot easier to glance over, see that it's fine, and then ignore. |
||
} | ||
#endregion | ||
} | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -223,6 +223,20 @@ internal static string EnsureNoTrailingSlash(string path) | |||||||||||||||||||||
return path; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||
/// Ensures the path does not have a leading or trailing slash. | ||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||
internal static string EnsureNoLeadingOrTrailingSlash(string path) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
if (String.IsNullOrEmpty(path)) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
return path; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
int start = IsSlash(path[0]) ? 1 : 0; | ||||||||||||||||||||||
int end = IsSlash(path[path.Length - 1]) ? 1 : 0; | ||||||||||||||||||||||
return path.Length - start - end > 0 ? path.Substring(start, path.Length - start - end) : String.Empty; | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if there's a more elegant way to express this, the best I could come up with is:
Suggested change
Probably not any better, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not reuse String.Trim(Char[]) to implement this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's actually really nice. Thanks for the suggestion! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Example: "\\hello" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm reasonably convinced that if there were multiple slashes on either side, that was a mistake because this is used for a path; there's no reason (unless you're explicitly trying to hack around a flawed implementation of EnsureNoLeadingSlash) to have multiple slashes in a row. Additionally, to comment on the fact that I no longer escaped projectDirectoryNoRoot: it was already escaped just above there, so I believe that was extra work to no benefit. If there is a reason that double-escaping something (and presumably double-unescaping something) is preferred, I can revert that part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thank you. How about the slash normalization done in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not confident about that and would actually guess that might be problematic, although the fact that it passed tests suggests it might be ok. To be safe, I'll add it back. Good catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And while I'm at it, I'm not sure why I should have to substring, then trim. Why not both at once? |
||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||
/// Indicates if the given file-spec ends with a slash. | ||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||
|
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.
Why can this be removed?