Skip to content

Implement StringIO#pread#56

Merged
kou merged 1 commit into
ruby:masterfrom
Shopify:pread
Jun 8, 2023
Merged

Implement StringIO#pread#56
kou merged 1 commit into
ruby:masterfrom
Shopify:pread

Conversation

@casperisfine

Copy link
Copy Markdown
Contributor

Both for being closer to real IOs and also because it's a convenient API in multithreaded scenarios.

cc @kddnewton @nobu

Comment thread ext/stringio/stringio.c Outdated
long offset = NUM2LONG(rb_offset);

if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add rb_len to error message?

Comment thread ext/stringio/stringio.c Outdated
}

if (offset < 0) {
rb_exc_raise(rb_syserr_new(EINVAL, "pread: Invalid offset argument"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add rb_offset to error message?

Comment thread ext/stringio/stringio.c Outdated
@casperisfine

Copy link
Copy Markdown
Contributor Author

@kou I applied your suggestions.

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need a review for JRuby part from @headius before we merge this.

Comment thread ext/stringio/stringio.c Outdated
Comment thread ext/stringio/stringio.c Outdated
Both for being closer to real IOs and also because it's a convenient
API in multithreaded scenarios.
@casperisfine

Copy link
Copy Markdown
Contributor Author

@kou done.

We need a review for JRuby part

No problem. Note that there are pre-existing failures on the JRuby suite, but the added test does pass on JRuby.

@headius headius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

JRuby part looks fine. I can do a small optimization (split out separate arities) once this is merged.

@kou kou merged commit 2b5e2a5 into ruby:master Jun 8, 2023
@kou

kou commented Jun 8, 2023

Copy link
Copy Markdown
Member

OK.
I've merged this.

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.

4 participants