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

Eliminate bounds checks in Bloom #7049

Merged
merged 1 commit into from
May 20, 2024
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
15 changes: 9 additions & 6 deletions src/Nethermind/Nethermind.Core/Bloom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ public void Add(LogEntry[] logEntries, Bloom? blockBloom = null)
LogEntry logEntry = logEntries[entryIndex];
byte[] addressBytes = logEntry.LoggersAddress.Bytes;
Set(addressBytes, blockBloom);
for (int topicIndex = 0; topicIndex < logEntry.Topics.Length; topicIndex++)
Hash256[] topics = logEntry.Topics;
for (int topicIndex = 0; topicIndex < topics.Length; topicIndex++)
{
Hash256 topic = logEntry.Topics[topicIndex];
Hash256 topic = topics[topicIndex];
Set(topic.Bytes, blockBloom);
}
}
Expand All @@ -148,9 +149,10 @@ public bool Matches(LogEntry logEntry)
{
if (Matches(logEntry.LoggersAddress))
{
for (int topicIndex = 0; topicIndex < logEntry.Topics.Length; topicIndex++)
Hash256[] topics = logEntry.Topics;
for (int topicIndex = 0; topicIndex < topics.Length; topicIndex++)
{
if (!Matches(logEntry.Topics[topicIndex]))
if (!Matches(topics[topicIndex]))
{
return false;
}
Expand Down Expand Up @@ -285,9 +287,10 @@ public readonly bool Matches(LogEntry logEntry)
{
if (Matches(logEntry.LoggersAddress))
{
for (int topicIndex = 0; topicIndex < logEntry.Topics.Length; topicIndex++)
Hash256[] topics = logEntry.Topics;
for (int topicIndex = 0; topicIndex < topics.Length; topicIndex++)
{
if (!Matches(logEntry.Topics[topicIndex]))
if (!Matches(topics[topicIndex]))
{
return false;
}
Expand Down
Loading