Skip to content
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

avoid multi enumeration warnings in TryGetStringBeforeChars #10358

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Docfx.MarkdigEngine.Extensions/ExtensionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static void SkipWhitespace(ref StringSlice slice)
}
}

public static string TryGetStringBeforeChars(IEnumerable<char> chars, ref StringSlice slice, bool breakOnWhitespace = false)
public static string TryGetStringBeforeChars(IReadOnlyList<char> chars, ref StringSlice slice, bool breakOnWhitespace = false)
{
StringSlice savedSlice = slice;
var c = slice.CurrentChar;
Expand Down Expand Up @@ -234,11 +234,11 @@ private static bool MatchPath(ref StringSlice slice, ref string path)
string includedFilePath;
if (slice.CurrentChar == '<')
{
includedFilePath = TryGetStringBeforeChars(new char[] { ')', '>' }, ref slice, breakOnWhitespace: true);
includedFilePath = TryGetStringBeforeChars([')', '>'], ref slice, breakOnWhitespace: true);
}
else
{
includedFilePath = TryGetStringBeforeChars(new char[] { ')' }, ref slice, breakOnWhitespace: true);
includedFilePath = TryGetStringBeforeChars([')'], ref slice, breakOnWhitespace: true);
}

if (includedFilePath == null)
Expand All @@ -259,7 +259,7 @@ private static bool MatchPath(ref StringSlice slice, ref string path)
}
else
{
var title = TryGetStringBeforeChars(new char[] { ')' }, ref slice, breakOnWhitespace: false);
var title = TryGetStringBeforeChars([')'], ref slice, breakOnWhitespace: false);
if (title == null)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Docfx.MarkdigEngine.Extensions/Noloc/NolocParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
return false;
}

var text = ExtensionsHelper.TryGetStringBeforeChars(new char[] { '\"', '\n' }, ref slice);
var text = ExtensionsHelper.TryGetStringBeforeChars(['\"', '\n'], ref slice);

if (text == null || text.Contains('\n'))
{
Expand Down