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

AK: Make some tweaks to AK::Span. #3166

Merged
merged 7 commits into from
Aug 15, 2020
Merged

AK: Make some tweaks to AK::Span. #3166

merged 7 commits into from
Aug 15, 2020

Conversation

asynts
Copy link
Member

@asynts asynts commented Aug 15, 2020

This pull request contains a few minor tweaks,

  • renames the span() methods on containers to bytes() if it is known at compile time that bytes are contained, and

  • adds some utility functions like Span::copy_to() or Span::fill() that are abstracting for memcpy(), memmove() and memset().

This assertion was added to prevent accitentally using stuff like
Span<int*> instead of Span<int>. But there can be spans of pointers.
I originally defined the bytes() method for the String class, because it
made it obvious that it's a span of bytes instead of span of characters.

This commit makes this more consistent by defining a bytes() method when
the type of the span is known to be u8.

Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and
such.
@awesomekling awesomekling merged commit fc27694 into SerenityOS:master Aug 15, 2020
@asynts asynts deleted the span branch August 15, 2020 19:21
AK/Span.h Show resolved Hide resolved
Libraries/LibCrypto/Cipher/Cipher.h Outdated Show resolved Hide resolved
Libraries/LibCrypto/Cipher/AES.h Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants