Skip to content

Commit

Permalink
more minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed May 28, 2024
1 parent 847d213 commit 560b997
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/EdgeDB.Net.QueryBuilder/Lexical/QueryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ public QueryWriter Term(TermType type, string name, Deferrable<string>? debug =
=> Term(type, name, debug, null, tokens);

public QueryWriter Term(TermType type, string name, Deferrable<string>? debug = null,
ITermMetadata? metadata = null, params Token[] values)
ITermMetadata? metadata = null, params Token[] tokens)
{
if (type is TermType.Verbose && !IsDebug)
{
Append(values);
Append(tokens);
return this;
}

if (values.Length == 0)
if (tokens.Length == 0)
return this;

var sizeDelta = Tokens.Count;
var position = TrackedPosition;

Append(out var slice, values);
Append(out var slice, tokens);

var size = Tokens.Count - sizeDelta;

Expand Down Expand Up @@ -288,29 +288,29 @@ public QueryWriter Append(in Token token, out TokenNodeSlice node, out int size)
public QueryWriter Append(in Token token)
=> Append(in token, out _);

public QueryWriter Append(params Token[] values)
public QueryWriter Append(params Token[] tokens)
{
for (var i = 0; i != values.Length; i++)
for (var i = 0; i != tokens.Length; i++)
{
AddAfterTracked(in values[i]);
AddAfterTracked(in tokens[i]);
}

UpdateTerms();

return this;
}

public QueryWriter Append(out TokenNodeSlice node, params Token[] values)
public QueryWriter Append(out TokenNodeSlice node, params Token[] tokens)
{
if (values.Length == 0)
if (tokens.Length == 0)
{
throw new ArgumentException("Values must contain at least 1 value");
}

node = AddAfterTracked(in values[0]);
node = AddAfterTracked(in tokens[0]);

for (var i = 1; i < values.Length; i++)
node.Tail = AddAfterTracked(in values[i]).Tail ?? node.Tail;
for (var i = 1; i < tokens.Length; i++)
node.Tail = AddAfterTracked(in tokens[i]).Tail ?? node.Tail;

UpdateTerms();

Expand Down
2 changes: 1 addition & 1 deletion src/EdgeDB.Net.QueryBuilder/QueryNodes/NodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public NodeBuilder(NodeContext context, List<QueryGlobal> globals, List<QueryNod
Nodes = nodes ?? new List<QueryNode>();
Context = context;
QueryGlobals = globals;
QueryVariables = variables ?? new Dictionary<string, object>();
QueryVariables = variables ?? new Dictionary<string, object?>();
}

/// <summary>
Expand Down

0 comments on commit 560b997

Please sign in to comment.