Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty keys #825

Merged
merged 8 commits into from
Jun 15, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions neo/SmartContract/InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,12 @@ private static bool PutEx(ApplicationEngine engine, StorageContext context, byte
if (engine.Snapshot.Storages.TryGet(skey)?.IsConstant == true) return false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we could access here to TrackableItem, we can save the GetAndChange

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetAndChange here doesn't access the internal storage. It read from the cache because we call TryGet before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we can know if the item has trackable.State = TrackState.Added; we can avoid the two reads

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is TrackState.Added, both the TryGet and GetAndChange calls read from the cache. These are all automatic.


// If put 'value' is empty (and non-const), we remove it (implicit `Storage.Delete`)
if ((value.Length == 0) && !flags.HasFlag(StorageFlags.Constant))
if (value.Length == 0)
{
engine.Snapshot.Storages.Delete(skey);
if (!flags.HasFlag(StorageFlags.Constant))
{
engine.Snapshot.Storages.Delete(skey);
}
igormcoelho marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down