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 30, 2024
1 parent 8f36223 commit 30893ef
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions RDFSharp/Query/Mirella/RDFQueryPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,13 @@ internal static string PrintConstructQuery(RDFConstructQuery constructQuery)
/// </summary>
internal static string PrintAskQuery(RDFAskQuery askQuery)
{
StringBuilder sb = new StringBuilder();
if (askQuery == null)
return sb.ToString();
return string.Empty;

#region PREFIXES
StringBuilder sb = new StringBuilder();
List<RDFNamespace> prefixes = PrintPrefixes(askQuery, sb, true);
#endregion

#region ASK
sb.AppendLine("ASK");
#endregion

#region WHERE
PrintWhereClause(askQuery, sb, prefixes, string.Empty, 0, false);
#endregion

return sb.ToString();
}
Expand Down Expand Up @@ -451,17 +443,19 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space
{
//Begin new UNION block
printingUnion = true;

result.AppendLine(string.Concat(spaces, " { ", PrintPattern(ptPgMember, prefixes), " }"));
result.AppendLine(string.Concat(spaces, " UNION"));
}

//Pattern is set as INTERSECT with the next pg member or it IS the last one => do not append UNION
else
{
//End active UNION block
if (printingUnion)
{
//End active UNION block
printingUnion = false;

result.AppendLine(string.Concat(spaces, " { ", PrintPattern(ptPgMember, prefixes), " }"));
}
else
Expand All @@ -473,10 +467,11 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space
#region PROPERTY PATH
else if (pgMember is RDFPropertyPath ppPgMember && ppPgMember.IsEvaluable)
{
//End active UNION block
if (printingUnion)
{
//End active UNION block
printingUnion = false;

result.AppendLine(string.Concat(spaces, " { ", PrintPropertyPath(ppPgMember, prefixes), " }"));
}
else
Expand All @@ -487,10 +482,11 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space
#region VALUES
else if (pgMember is RDFValues vlPgMember && vlPgMember.IsEvaluable && !vlPgMember.IsInjected)
{
//End active UNION block
if (printingUnion)
{
//End active UNION block
printingUnion = false;

result.AppendLine(string.Concat(spaces, " { ", PrintValues(vlPgMember, prefixes, spaces), " }"));
}
else
Expand All @@ -502,8 +498,8 @@ internal static string PrintPatternGroup(RDFPatternGroup patternGroup, int space
else if (pgMember is RDFBind bdPgMember)
{
//End active UNION block
if (printingUnion)
printingUnion = false;
printingUnion = false;

result.AppendLine(string.Concat(spaces, " ", PrintBind(bdPgMember, prefixes), " ."));
}
#endregion
Expand Down

0 comments on commit 30893ef

Please sign in to comment.