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

[cleanup] Clean up the way strings are created from OutBuffer #3154

Merged
4 commits merged into from Jan 26, 2014

Conversation

yebblies
Copy link
Member

  • Introduce extractString which appends a '\0' if necessary then takes ownership of the data
  • Replace toChars with peekString which appends a '\0' if necessary then returns a reference to the internal buffer
  • Remove writebyte which is just a less-popular alias of writeByte

toChars is especially nasty in that it does not return a unique heap-backed string unlike Object::toChars.

See also: https://d.puremagic.com/issues/show_bug.cgi?id=9421

@AndrejMitrovic

@@ -63,7 +62,7 @@ struct OutBuffer
void spread(size_t offset, size_t nbytes);
size_t insert(size_t offset, const void *data, size_t nbytes);
void remove(size_t offset, size_t nbytes);
char *toChars();
char *peekString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment, please? ;)
(Just what you also explained in the pull request description.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ghost
Copy link

ghost commented Jan 26, 2014

LGTM, just add doc comments in the function declarations.

@yebblies
Copy link
Member Author

Updated.

@ghost
Copy link

ghost commented Jan 26, 2014

Auto-merge toggled on

ghost pushed a commit that referenced this pull request Jan 26, 2014
[cleanup] Clean up the way strings are created from `OutBuffer`
@ghost ghost merged commit dd5aa3c into dlang:master Jan 26, 2014
@yebblies yebblies deleted the extractstring branch January 26, 2014 13:01
@yebblies
Copy link
Member Author

Thanks!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants