Skip to content

Commit

Permalink
Slight code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesalvo committed Nov 26, 2023
1 parent 21a2bb4 commit 096a0e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
6 changes: 0 additions & 6 deletions RDFSharp/Model/Validation/RDFValidationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,13 @@ internal static List<RDFPatternMember> GetInstancesOfClass(this RDFGraph dataGra
{
#region visitContext
if (visitContext == null)
{
visitContext = new HashSet<long>() { { className.PatternMemberID } };
}
else
{
if (!visitContext.Contains(className.PatternMemberID))
{
visitContext.Add(className.PatternMemberID);
}
else
{
return result;
}
}
#endregion

Expand Down
22 changes: 7 additions & 15 deletions RDFSharp/Store/RDFContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,22 @@ public RDFContext() : this(RDFNamespaceRegister.DefaultNamespace.NamespaceUri) {
public RDFContext(string ctxUri)
{
Uri tempUri = RDFModelUtilities.GetUriFromString(ctxUri);

#region Guards
if (tempUri == null)
throw new RDFStoreException("Cannot create RDFContext because given \"ctxUri\" parameter is null or does not represent a valid Uri.");
if (tempUri.ToString().StartsWith("bnode:", StringComparison.OrdinalIgnoreCase) || tempUri.ToString().StartsWith("xmlns:", StringComparison.OrdinalIgnoreCase))
if (tempUri.ToString().StartsWith("bnode:", StringComparison.OrdinalIgnoreCase)
|| tempUri.ToString().StartsWith("xmlns:", StringComparison.OrdinalIgnoreCase))
throw new RDFStoreException("Cannot create RDFContext because given \"ctxUri\" parameter represents a blank node Uri.");

#endregion

Context = tempUri;
}

/// <summary>
/// Uri-based ctor to build a context from the given Uri
/// </summary>
public RDFContext(Uri ctxUri)
{
if (ctxUri == null)
throw new RDFStoreException("Cannot create RDFContext because given \"ctxUri\" parameter is null.");

Uri tempUri = RDFModelUtilities.GetUriFromString(ctxUri.ToString());
if (tempUri == null)
throw new RDFStoreException("Cannot create RDFContext because given \"ctxUri\" parameter does not represent a valid Uri.");
if (tempUri.ToString().StartsWith("bnode:", StringComparison.OrdinalIgnoreCase) || tempUri.ToString().StartsWith("xmlns:", StringComparison.OrdinalIgnoreCase))
throw new RDFStoreException("Cannot create RDFContext because given \"ctxUri\" parameter represents a blank node Uri.");

Context = tempUri;
}
public RDFContext(Uri ctxUri) : this(ctxUri?.ToString()) { }
#endregion

#region Interfaces
Expand Down

0 comments on commit 096a0e2

Please sign in to comment.