Skip to content

Commit

Permalink
chore: avoid multi enumeration warnings in TryGetStringBeforeChars (#…
Browse files Browse the repository at this point in the history
…10358)

* avoid multi enumeration warnings in TryGetStringBeforeChars

* Revert "test: generate public API contract"

This reverts commit 1613584

---------

Co-authored-by: Yufei Huang <[email protected]>
  • Loading branch information
SimonCropp and yufeih authored Nov 8, 2024
1 parent 7bd00cd commit 305748b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Docfx.MarkdigEngine.Extensions/ExtensionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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 @@ -239,11 +239,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 @@ -264,7 +264,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

0 comments on commit 305748b

Please sign in to comment.