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 30893ef commit affae6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions RDFSharp/Query/Mirella/Algebra/RDFAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal string PrintHavingClause(List<RDFNamespace> prefixes)
StringBuilder result = new StringBuilder();
if (HavingClause.Item1)
{
result.Append("(");
result.Append('(');
result.Append(ToString().Substring(1, ToString().LastIndexOf(" AS ?")));
switch (HavingClause.Item2)
{
Expand All @@ -160,7 +160,7 @@ internal string PrintHavingClause(List<RDFNamespace> prefixes)
break;
}
result.Append(RDFQueryPrinter.PrintPatternMember(HavingClause.Item3, prefixes));
result.Append(")");
result.Append(')');
}
return result.ToString();
}
Expand Down
4 changes: 2 additions & 2 deletions RDFSharp/Query/Mirella/RDFOperationPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static string PrintInsertDataOperation(RDFInsertDataOperation insertDat
#region TEMPLATES
sb.AppendLine("INSERT DATA {");
insertDataOperation.InsertTemplates.ForEach(tp => sb.Append(PrintPattern(prefixes, tp)));
sb.Append("}");
sb.Append('}');
#endregion
}

Expand Down Expand Up @@ -88,7 +88,7 @@ internal static string PrintDeleteDataOperation(RDFDeleteDataOperation deleteDat

sb.AppendLine("DELETE DATA {");
deleteDataOperation.DeleteTemplates.ForEach(tp => sb.Append(PrintPattern(prefixes, tp)));
sb.Append("}");
sb.Append('}');
}

return sb.ToString();
Expand Down
24 changes: 12 additions & 12 deletions RDFSharp/Query/Mirella/RDFQueryPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ int subqueryUnionSpacesFunc(bool union)
.ToList()
.ForEach(gm =>
{
sb.Append(" ");
sb.Append(' ');
sb.Append(string.Join(" ", gm.PartitionVariables));
sb.Append(" ");
sb.Append(' ');
sb.Append(string.Join(" ", gm.Aggregators.Where(ag => !(ag is RDFPartitionAggregator))));
});
}
Expand Down Expand Up @@ -562,14 +562,14 @@ internal static string PrintPropertyPath(RDFPropertyPath propertyPath, List<RDFN
{
StringBuilder result = new StringBuilder();
result.Append(PrintPatternMember(propertyPath.Start, prefixes));
result.Append(" ");
result.Append(' ');

#region Single Property
if (propertyPath.Steps.Count == 1)
{
//InversePath (will swap start/end)
if (propertyPath.Steps[0].IsInverseStep)
result.Append("^");
result.Append('^');

RDFResource propPath = propertyPath.Steps[0].StepProperty;
result.Append(PrintPatternMember(propPath, prefixes));
Expand All @@ -591,12 +591,12 @@ internal static string PrintPropertyPath(RDFPropertyPath propertyPath, List<RDFN
if (!openedParenthesis)
{
openedParenthesis = true;
result.Append("(");
result.Append('(');
}

//InversePath (will swap start/end)
if (propertyPath.Steps[i].IsInverseStep)
result.Append("^");
result.Append('^');

var propPath = propertyPath.Steps[i].StepProperty;
if (i < propertyPath.Steps.Count - 1)
Expand All @@ -607,7 +607,7 @@ internal static string PrintPropertyPath(RDFPropertyPath propertyPath, List<RDFN
else
{
result.Append(PrintPatternMember(propPath, prefixes));
result.Append(")");
result.Append(')');
}
}

Expand All @@ -623,7 +623,7 @@ internal static string PrintPropertyPath(RDFPropertyPath propertyPath, List<RDFN

//InversePath (will swap start/end)
if (propertyPath.Steps[i].IsInverseStep)
result.Append("^");
result.Append('^');

var propPath = propertyPath.Steps[i].StepProperty;
if (i < propertyPath.Steps.Count - 1)
Expand All @@ -638,7 +638,7 @@ internal static string PrintPropertyPath(RDFPropertyPath propertyPath, List<RDFN
}
#endregion

result.Append(" ");
result.Append(' ');
result.Append(PrintPatternMember(propertyPath.End, prefixes));
return result.ToString();
}
Expand All @@ -661,9 +661,9 @@ internal static string PrintValues(RDFValues values, List<RDFNamespace> prefixes
result.Append("UNDEF");
else
result.Append(RDFQueryPrinter.PrintPatternMember(binding, prefixes));
result.Append(" ");
result.Append(' ');
}
result.Append("}");
result.Append('}');
}

//Extended representation
Expand All @@ -681,7 +681,7 @@ internal static string PrintValues(RDFValues values, List<RDFNamespace> prefixes
result.Append("UNDEF");
else
result.Append(RDFQueryPrinter.PrintPatternMember(bindingValue, prefixes));
result.Append(" ");
result.Append(' ');
});
result.AppendLine(")");
}
Expand Down

0 comments on commit affae6c

Please sign in to comment.