-
Notifications
You must be signed in to change notification settings - Fork 176
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
Excessive bounds checking when reading multi-byte values #62
Comments
Approaches in the direction of Virtual calls can be inlined when the compiler knows it's dealing with a sealed type. Haven't looked to see if this actually happens, but it's a pretty niche optimization regardless. |
Fixes #62 Adds a new abstract overload for reading a single byte. That method will not do any explicit bounds validation, so callers must do that beforehand. In cases where multiple bytes are read, the validation can be performed once per value, rather than once per byte.
Fixes #62 Adds a new abstract overload for reading a single byte. That method will not do any explicit bounds validation, so callers must do that beforehand. In cases where multiple bytes are read, the validation can be performed once per value, rather than once per byte.
For example,
ByteArrayReader.GetInt32
validates the index for four bytes. It then callsGetByte
four times, which causes a further four validations.One potential solution is to have a non-public
GetByteInternal
method that doesn't validate.Investigate at the same time whether we can have the
GetByte
calls be inlined. Being virtual probably nixes that.The text was updated successfully, but these errors were encountered: