-
Notifications
You must be signed in to change notification settings - Fork 267
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: improve mem reading in Memory #2667
base: master
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. I have a few comments, mostly cosmetics and nitpicks. Doesn't prevent the approval.
Question, I didn't see any test regarding some classes you created. Like the ones to convert to HexString or the arraycopy on MemorySlice. Do we already have these operations covered in other tests and wasn't necessary to add one?
rskj-core/src/main/java/co/rsk/core/types/bytes/HexPrintableBytes.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/core/types/bytes/HexPrintableBytes.java
Outdated
Show resolved
Hide resolved
return toHexString(0, length()); | ||
} | ||
|
||
default String toHexStringV2(int off, int length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this v2 method? Can not we just use the default String toHexString(int off, int length)
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to emphasise that this is another version comparing to ByteUtil#toHexString(), which uses a 3rd-party lib. Added javadoc here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also added jmh test here
@@ -128,6 +128,42 @@ default Bytes copyBytes() { | |||
default BytesSlice slice(int from, int to) { | |||
return new BytesSliceImpl(this, from, to); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about convert this class to an abstract class? I think it could give us various advantages:
- We could make both equals and hashcode methods part of the class and not implemented as static.
- We can force the usage of
BoundaryUtils.checkArrayIndexParam(length(), index)
- Stop using default methods for defining common implementations and facilitate the testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use interface
here. I guess it's quite similar to CharSequence
interface that's being used for chars without concrete implementation of equals
and hashCode
d3d49aa
to
97593a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test addition and refactor. Looks good.
f243260
to
39f9c56
Compare
The base branch was changed.
97593a2
to
5842372
Compare
@@ -181,21 +185,20 @@ | |||
} | |||
|
|||
/** @see org.ethereum.crypto.cryptohash.Digest */ | |||
public void update(byte[] input) | |||
public void update(BytesSlice input) |
Check notice
Code scanning / CodeQL
Missing Override annotation Note
Digest.update
} | ||
|
||
/** @see org.ethereum.crypto.cryptohash.Digest */ | ||
public void update(byte[] input, int offset, int len) | ||
public void update(BytesSlice input, int offset, int len) |
Check notice
Code scanning / CodeQL
Missing Override annotation Note
Digest.update
dfaf622
to
bc1b4b6
Compare
bc1b4b6
to
4aef18d
Compare
4aef18d
to
e1d6fd4
Compare
Quality Gate passedIssues Measures |
Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: