Skip to content

Commit d6b9eb3

Browse files
Use concurrent dictionary, fix namespace
1 parent de5872e commit d6b9eb3

File tree

11 files changed

+17
-14
lines changed

11 files changed

+17
-14
lines changed

src/SixLabors.Fonts/StreamFontMetrics.Cff.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using SixLabors.Fonts.Tables.General.Kern;
1010
using SixLabors.Fonts.Tables.General.Name;
1111
using SixLabors.Fonts.Tables.General.Post;
12-
using SixLabors.Fonts.Tables.Svg;
12+
using SixLabors.Fonts.Tables.General.Svg;
1313
using SixLabors.Fonts.Unicode;
1414

1515
namespace SixLabors.Fonts;

src/SixLabors.Fonts/StreamFontMetrics.TrueType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using SixLabors.Fonts.Tables.General.Kern;
1010
using SixLabors.Fonts.Tables.General.Name;
1111
using SixLabors.Fonts.Tables.General.Post;
12-
using SixLabors.Fonts.Tables.Svg;
12+
using SixLabors.Fonts.Tables.General.Svg;
1313
using SixLabors.Fonts.Tables.TrueType;
1414
using SixLabors.Fonts.Tables.TrueType.Glyphs;
1515
using SixLabors.Fonts.Tables.TrueType.Hinting;

src/SixLabors.Fonts/Tables/Cff/CompactFontTables.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using SixLabors.Fonts.Tables.General.Kern;
88
using SixLabors.Fonts.Tables.General.Name;
99
using SixLabors.Fonts.Tables.General.Post;
10-
using SixLabors.Fonts.Tables.Svg;
10+
using SixLabors.Fonts.Tables.General.Svg;
1111

1212
namespace SixLabors.Fonts.Tables.Cff;
1313

src/SixLabors.Fonts/Tables/General/Colr/ColrV0GlyphSource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4+
using System.Collections.Concurrent;
45
using System.Numerics;
56
using SixLabors.Fonts.Rendering;
67
using SixLabors.Fonts.Tables.TrueType.Glyphs;
@@ -13,7 +14,7 @@ namespace SixLabors.Fonts.Tables.General.Colr;
1314
/// </summary>
1415
internal sealed class ColrV0GlyphSource : ColrGlyphSourceBase
1516
{
16-
private static readonly Dictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
17+
private static readonly ConcurrentDictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
1718

1819
/// <summary>
1920
/// Initializes a new instance of the <see cref="ColrV0GlyphSource"/> class.

src/SixLabors.Fonts/Tables/General/Colr/ColrV1GlyphSource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4+
using System.Collections.Concurrent;
45
using System.Numerics;
56
using SixLabors.Fonts.Rendering;
67
using SixLabors.Fonts.Tables.TrueType.Glyphs;
@@ -13,7 +14,7 @@ namespace SixLabors.Fonts.Tables.General.Colr;
1314
/// </summary>
1415
internal sealed class ColrV1GlyphSource : ColrGlyphSourceBase
1516
{
16-
private static readonly Dictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
17+
private static readonly ConcurrentDictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
1718

1819
/// <summary>
1920
/// Initializes a new instance of the <see cref="ColrV1GlyphSource"/> class.

src/SixLabors.Fonts/Tables/Svg/SvgDocumentIndexEntry.cs renamed to src/SixLabors.Fonts/Tables/General/Svg/SvgDocumentIndexEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace SixLabors.Fonts.Tables.Svg;
4+
namespace SixLabors.Fonts.Tables.General.Svg;
55

66
internal readonly struct SvgDocumentIndexEntry
77
{

src/SixLabors.Fonts/Tables/Svg/SvgGlyphSource.cs renamed to src/SixLabors.Fonts/Tables/General/Svg/SvgGlyphSource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using SixLabors.Fonts.Rendering;
1212

1313
#pragma warning disable SA1201 // Elements should appear in the correct order
14-
namespace SixLabors.Fonts.Tables.Svg;
14+
namespace SixLabors.Fonts.Tables.General.Svg;
1515

1616
/// <summary>
1717
/// Supplies painted glyphs (layers + commands + paints) and canvas metadata for OT-SVG glyphs.
@@ -21,8 +21,8 @@ namespace SixLabors.Fonts.Tables.Svg;
2121
internal sealed class SvgGlyphSource : IPaintedGlyphSource
2222
{
2323
private readonly SvgTable svgTable;
24-
private static readonly Dictionary<ushort, ParsedDoc> DocCache = [];
25-
private static readonly Dictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
24+
private static readonly ConcurrentDictionary<ushort, ParsedDoc> DocCache = [];
25+
private static readonly ConcurrentDictionary<ushort, (PaintedGlyph Glyph, PaintedCanvas Canvas)> CachedGlyphs = [];
2626

2727
private sealed class ParsedDoc
2828
{

src/SixLabors.Fonts/Tables/Svg/SvgTable.cs renamed to src/SixLabors.Fonts/Tables/General/Svg/SvgTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.IO.Compression;
55
using System.Runtime.CompilerServices;
66

7-
namespace SixLabors.Fonts.Tables.Svg;
7+
namespace SixLabors.Fonts.Tables.General.Svg;
88

99
internal class SvgTable : Table
1010
{

src/SixLabors.Fonts/Tables/TableLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using SixLabors.Fonts.Tables.General.Kern;
99
using SixLabors.Fonts.Tables.General.Name;
1010
using SixLabors.Fonts.Tables.General.Post;
11-
using SixLabors.Fonts.Tables.Svg;
11+
using SixLabors.Fonts.Tables.General.Svg;
1212
using SixLabors.Fonts.Tables.TrueType;
1313
using SixLabors.Fonts.Tables.TrueType.Glyphs;
1414
using SixLabors.Fonts.Tables.TrueType.Hinting;

src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphTable.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4+
using System.Collections.Concurrent;
45
using SixLabors.Fonts.Tables.Woff;
56

67
namespace SixLabors.Fonts.Tables.TrueType.Glyphs;
@@ -9,12 +10,12 @@ internal class GlyphTable : Table
910
{
1011
internal const string TableName = "glyf";
1112
private readonly GlyphLoader[] loaders;
12-
private readonly Dictionary<int, GlyphVector> glyphCache;
13+
private readonly ConcurrentDictionary<int, GlyphVector> glyphCache;
1314

1415
public GlyphTable(GlyphLoader[] glyphLoaders)
1516
{
1617
this.loaders = glyphLoaders;
17-
this.glyphCache = new(glyphLoaders.Length);
18+
this.glyphCache = new(Environment.ProcessorCount, glyphLoaders.Length);
1819
}
1920

2021
public int GlyphCount => this.loaders.Length;

0 commit comments

Comments
 (0)