-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve framing performance with large sets of objects. (#32)
- Loading branch information
1 parent
508c988
commit 66f585b
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace JsonLD.Core | ||
{ | ||
internal sealed class JsonLdSet | ||
{ | ||
private readonly Lazy<HashSet<string>> _objects; | ||
|
||
internal JsonLdSet() | ||
{ | ||
_objects = new Lazy<HashSet<string>>(() => new HashSet<string>(StringComparer.Ordinal)); | ||
} | ||
|
||
internal bool Add(JToken token) | ||
{ | ||
if (token == null) | ||
{ | ||
throw new ArgumentNullException(nameof(token)); | ||
} | ||
|
||
if (token is JObject) | ||
{ | ||
var id = token["@id"]; | ||
|
||
return id != null && _objects.Value.Add(id.Value<string>()); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters