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

Perf: use manual masking on state flags to avoid boxing #1197

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1197,33 +1197,38 @@ private void SetSnapshottedState(SnapshottedStateFlags flag, bool value)
}
}

private bool GetSnapshottedState(SnapshottedStateFlags flag)
{
return (_snapshottedState & flag) == flag;
}

internal bool HasOpenResult
{
get => _snapshottedState.HasFlag(SnapshottedStateFlags.OpenResult);
get => GetSnapshottedState(SnapshottedStateFlags.OpenResult);
set => SetSnapshottedState(SnapshottedStateFlags.OpenResult, value);
}

internal bool HasPendingData
{
get => _snapshottedState.HasFlag(SnapshottedStateFlags.PendingData);
get => GetSnapshottedState(SnapshottedStateFlags.PendingData);
set => SetSnapshottedState(SnapshottedStateFlags.PendingData, value);
}

internal bool HasReceivedError
{
get => _snapshottedState.HasFlag(SnapshottedStateFlags.ErrorTokenReceived);
get => GetSnapshottedState(SnapshottedStateFlags.ErrorTokenReceived);
set => SetSnapshottedState(SnapshottedStateFlags.ErrorTokenReceived, value);
}

internal bool HasReceivedAttention
{
get => _snapshottedState.HasFlag(SnapshottedStateFlags.AttentionReceived);
get => GetSnapshottedState(SnapshottedStateFlags.AttentionReceived);
set => SetSnapshottedState(SnapshottedStateFlags.AttentionReceived, value);
}

internal bool HasReceivedColumnMetadata
{
get => _snapshottedState.HasFlag(SnapshottedStateFlags.ColMetaDataReceived);
get => GetSnapshottedState(SnapshottedStateFlags.ColMetaDataReceived);
set => SetSnapshottedState(SnapshottedStateFlags.ColMetaDataReceived, value);
}

Expand Down Expand Up @@ -4289,11 +4294,11 @@ internal void ResetSnapshotState()
_stateObj._cleanupAltMetaDataSetArray = _snapshotCleanupAltMetaDataSetArray;

// Make sure to go through the appropriate increment/decrement methods if changing the OpenResult flag
if (!_stateObj.HasOpenResult && _state.HasFlag(SnapshottedStateFlags.OpenResult))
if (!_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) == SnapshottedStateFlags.OpenResult))
{
_stateObj.IncrementAndObtainOpenResultCount(_stateObj._executedUnderTransaction);
}
else if (_stateObj.HasOpenResult && !_state.HasFlag(SnapshottedStateFlags.OpenResult))
else if (_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) != SnapshottedStateFlags.OpenResult))
{
_stateObj.DecrementOpenResultCount();
}
Expand Down