Use statically initialized data

This commit is contained in:
Jason Nelson 2024-03-13 18:36:47 -07:00 committed by BobLd
parent 4653671b2d
commit e508d6714e
3 changed files with 8 additions and 15 deletions

View File

@ -15,15 +15,15 @@
private const byte Offset = (byte)'!'; private const byte Offset = (byte)'!';
private const byte EmptyCharacterPadding = (byte) 'u'; private const byte EmptyCharacterPadding = (byte) 'u';
private static readonly byte[] EndOfDataBytes = { (byte)'~', (byte)'>' }; private static ReadOnlySpan<byte> EndOfDataBytes => [(byte)'~', (byte)'>'];
private static readonly int[] PowerByIndex = { private static readonly int[] PowerByIndex = [
1, 1,
85, 85,
85 * 85, 85 * 85,
85 * 85 * 85, 85 * 85 * 85,
85 * 85 * 85 *85 85 * 85 * 85 *85
}; ];
/// <inheritdoc /> /// <inheritdoc />
public bool IsSupported { get; } = true; public bool IsSupported { get; } = true;

View File

@ -26,18 +26,7 @@
/// </summary> /// </summary>
private const int EndOfFileSearchRange = 2048; private const int EndOfFileSearchRange = 2048;
private static readonly byte[] StartXRefBytes = private static ReadOnlySpan<byte> StartXRefBytes => "startxref"u8;
{
(byte) 's',
(byte) 't',
(byte) 'a',
(byte) 'r',
(byte) 't',
(byte) 'x',
(byte) 'r',
(byte) 'e',
(byte) 'f'
};
public static long GetFirstCrossReferenceOffset(IInputBytes bytes, ISeekableTokenScanner scanner, bool isLenientParsing) public static long GetFirstCrossReferenceOffset(IInputBytes bytes, ISeekableTokenScanner scanner, bool isLenientParsing)
{ {

View File

@ -31,7 +31,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462' OR '$(TargetFramework)'=='net47'"> <ItemGroup Condition="'$(TargetFramework)'=='net462' OR '$(TargetFramework)'=='net47'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\UglyToad.PdfPig.Core\UglyToad.PdfPig.Core.csproj" /> <ProjectReference Include="..\UglyToad.PdfPig.Core\UglyToad.PdfPig.Core.csproj" />
<ProjectReference Include="..\UglyToad.PdfPig.Fonts\UglyToad.PdfPig.Fonts.csproj" /> <ProjectReference Include="..\UglyToad.PdfPig.Fonts\UglyToad.PdfPig.Fonts.csproj" />