Skip to content

Commit

Permalink
dont opt now
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Oct 1, 2024
1 parent 7e659a5 commit 8948927
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/SpacetimeDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static int BsatnRowListCount(BsatnRowList list)
}
}

private static IEnumerable<ReadOnlyMemory<byte>> BsatnRowListIter(BsatnRowList list)
private static IEnumerable<byte[]> BsatnRowListIter(BsatnRowList list)
{
var count = BsatnRowListCount(list);
for (int index = 0; index < count; index += 1)
Expand Down Expand Up @@ -287,7 +287,7 @@ private static IEnumerable<ReadOnlyMemory<byte>> BsatnRowListIter(BsatnRowList l
end = (int)offsets[index + 1];
}
int elemLen = end - start;
yield return new ReadOnlyMemory<byte>(list.RowsData, start, elemLen);
yield return new ReadOnlyMemory<byte>(list.RowsData, start, elemLen).ToArray();
break;
}
}
Expand Down Expand Up @@ -323,7 +323,7 @@ PreProcessedMessage PreProcessMessage(UnprocessedMessage unprocessed)
// All row updates that have a primary key, this contains inserts, deletes and updates
var primaryKeyChanges = new Dictionary<(System.Type tableType, object primaryKeyValue), DbOp>();

HashSet<ReadOnlyMemory<byte>> GetInsertHashSet(System.Type tableType, int tableSize)
HashSet<byte[]> GetInsertHashSet(System.Type tableType, int tableSize)
{
if (!subscriptionInserts.TryGetValue(tableType, out var hashSet))
{
Expand Down Expand Up @@ -369,12 +369,11 @@ HashSet<ReadOnlyMemory<byte>> GetInsertHashSet(System.Type tableType, int tableS
continue;
}

var bytes = bin.ToArray();
var obj = table.DecodeValue(bytes);
var obj = table.DecodeValue(bin);
var op = new DbOp
{
table = table,
insert = new(obj, bytes),
insert = new(obj, bin),
};

dbOps.Add(op);
Expand Down Expand Up @@ -427,8 +426,7 @@ HashSet<ReadOnlyMemory<byte>> GetInsertHashSet(System.Type tableType, int tableS
var qu = DecompressDecodeQueryUpdate(cqu);
foreach (var row in BsatnRowListIter(qu.Inserts))
{
var bytes = row.ToArray();
var op = new DbOp { table = table, insert = Decode(table, bytes, out var pk) };
var op = new DbOp { table = table, insert = Decode(table, row, out var pk) };
if (pk != null)
{
// Compound key that we use for lookup.
Expand Down Expand Up @@ -463,8 +461,7 @@ HashSet<ReadOnlyMemory<byte>> GetInsertHashSet(System.Type tableType, int tableS

foreach (var row in BsatnRowListIter(qu.Deletes))
{
var bytes = row.ToArray();
var op = new DbOp { table = table, delete = Decode(table, bytes, out var pk) };
var op = new DbOp { table = table, delete = Decode(table, row, out var pk) };
if (pk != null)
{
// Compound key that we use for lookup.
Expand Down Expand Up @@ -896,7 +893,7 @@ T[] LogAndThrow(string error)
}

return BsatnRowListIter(resultTable.Rows)
.Select(row => BSATNHelpers.Decode<T>(row.ToArray()))
.Select(row => BSATNHelpers.Decode<T>(row))
.ToArray();
}

Expand Down

0 comments on commit 8948927

Please sign in to comment.