Skip to content

Commit

Permalink
Few more minor opts
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed May 13, 2024
1 parent 867675c commit 9bbad08
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/SpacetimeDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,15 @@ HashSet<byte[]> GetInsertHashSet(string tableName, int tableSize)
}
var (insertOp, deleteOp) = op.insert is not null ? (op, oldOp) : (oldOp, op);

primaryKeyLookup[primaryKeyValue] = new DbOp
op = new DbOp
{
table = insertOp.table,
delete = deleteOp.delete,
insert = insertOp.insert,
rowValue = insertOp.rowValue,
};
}
else
{
primaryKeyLookup[primaryKeyValue] = op;
}
primaryKeyLookup[primaryKeyValue] = op;
}
else
{
Expand Down Expand Up @@ -506,23 +503,20 @@ void ExecuteStateDiff()
{
foreach (var table in clientDB.GetTables())
{
foreach (var rowBytes in table.entries.Keys)
if (!preProcessedMessage.inserts.TryGetValue(table.Name, out var hashSet))
{
if (!preProcessedMessage.inserts.TryGetValue(table.Name, out var hashSet))
{
continue;
}
continue;
}

if (!hashSet.Contains(rowBytes))
foreach (var (rowBytes, oldValue) in table.entries.Where(kv => !hashSet.Contains(kv.Key)))
{
dbOps.Add(new DbOp
{
table = table,
// This is a row that we had before, but we do not have it now.
// This must have been a delete.
dbOps.Add(new DbOp
{
table = table,
delete = new(table.entries[rowBytes].Item2, rowBytes),
});
}
delete = new(oldValue.Item2, rowBytes),
});
}
}
}
Expand Down

0 comments on commit 9bbad08

Please sign in to comment.