mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
* Introduce ValueStringBuilder * Make NumericTokenizer and PlanTextTokenizer thread-safe * Replace ListPool with ArrayPoolBufferWriter * Seal ITokenizer classes * Eliminate array allocation in Type1ArrayTokenizer * Eliminate array allocation in AcroFormFactory * Eliminate StringBuilder allocation in Page.GetText * Optimize PdfSubpath.ToLines * Eliminate various allocations when parsing CompactFontFormat * Remove unused FromOctalInt helper * Ensure Pdf.Content is not null * Write ASCII values directly to stream (avoiding allocations) * Avoid encoding additional ASCII values * Eliminate allocations in TokenWriter.WriteName * Eliminate allocation in TokenWriter.WriteNumber * Add System.Memory reference to Fonts
33 lines
786 B
C#
33 lines
786 B
C#
namespace UglyToad.PdfPig.Tokenization
|
|
{
|
|
using Core;
|
|
using System.Text;
|
|
using Tokens;
|
|
|
|
internal sealed class CommentTokenizer : ITokenizer
|
|
{
|
|
public bool ReadsNextByte { get; } = true;
|
|
|
|
public bool TryTokenize(byte currentByte, IInputBytes inputBytes, out IToken token)
|
|
{
|
|
token = null;
|
|
|
|
if (currentByte != '%')
|
|
{
|
|
return false;
|
|
}
|
|
|
|
using var builder = new ValueStringBuilder();
|
|
|
|
while (inputBytes.MoveNext() && !ReadHelper.IsEndOfLine(inputBytes.CurrentByte))
|
|
{
|
|
builder.Append((char) inputBytes.CurrentByte);
|
|
}
|
|
|
|
token = new CommentToken(builder.ToString());
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|