mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 02:44:58 +08:00
add a bunch more performance improvements
filter provider becomes single instance and no longer has constructor parameters. tokenizers use list and stringbuilder pools to reduce allocations. system font finder becomes static to preserve file cache across all documents.
This commit is contained in:
@@ -2,18 +2,16 @@
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PdfPig.Filters;
|
||||
using PdfPig.Tokens;
|
||||
using PdfPig.Filters;
|
||||
using Xunit;
|
||||
|
||||
public class DecodeParameterResolverTests
|
||||
{
|
||||
private readonly DecodeParameterResolver resolver= new DecodeParameterResolver(new TestingLog());
|
||||
|
||||
[Fact]
|
||||
public void NullDictionary_Throws()
|
||||
{
|
||||
Action action = () => resolver.GetFilterParameters(null, 0);
|
||||
Action action = () => DecodeParameterResolver.GetFilterParameters(null, 0);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(action);
|
||||
}
|
||||
@@ -21,7 +19,7 @@
|
||||
[Fact]
|
||||
public void NegativeIndex_Throws()
|
||||
{
|
||||
Action action = () => resolver.GetFilterParameters(new DictionaryToken(new Dictionary<NameToken, IToken>()), -1);
|
||||
Action action = () => DecodeParameterResolver.GetFilterParameters(new DictionaryToken(new Dictionary<NameToken, IToken>()), -1);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(action);
|
||||
}
|
||||
@@ -29,7 +27,7 @@
|
||||
[Fact]
|
||||
public void EmptyDictionary_ReturnsEmptyDictionary()
|
||||
{
|
||||
var result = resolver.GetFilterParameters(new DictionaryToken(new Dictionary<NameToken, IToken>()), 0);
|
||||
var result = DecodeParameterResolver.GetFilterParameters(new DictionaryToken(new Dictionary<NameToken, IToken>()), 0);
|
||||
|
||||
Assert.Empty(result.Data);
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
public class FlateFilterTests
|
||||
{
|
||||
private readonly FlateFilter filter = new FlateFilter(new DecodeParameterResolver(new TestingLog()), new PngPredictor(), new TestingLog());
|
||||
private readonly FlateFilter filter = new FlateFilter();
|
||||
|
||||
[Fact]
|
||||
public void EncodeAndDecodePreservesInput()
|
||||
|
@@ -100,7 +100,7 @@
|
||||
{NameToken.DecodeParms, paramsDict}
|
||||
});
|
||||
|
||||
var filter = new FlateFilter(new DecodeParameterResolver(null), new PngPredictor(), null);
|
||||
var filter = new FlateFilter();
|
||||
var filtered = filter.Decode(streamBytes, dictionary, 0);
|
||||
|
||||
var expected =
|
||||
|
Reference in New Issue
Block a user