Skip to content

ZJIT: Inline String#empty?#15283

Merged
tekknolagi merged 1 commit intoruby:masterfrom
tekknolagi:mb-specialize-string-empty-p
Nov 21, 2025
Merged

ZJIT: Inline String#empty?#15283
tekknolagi merged 1 commit intoruby:masterfrom
tekknolagi:mb-specialize-string-empty-p

Conversation

@tekknolagi
Copy link
Contributor

Don't emit a CCall.

Don't emit a CCall.
}

fn inline_string_empty_p(fun: &mut hir::Function, block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], _state: hir::InsnId) -> Option<hir::InsnId> {
let &[] = args else { return None; };
Copy link
Contributor

@nirvdrum nirvdrum Nov 21, 2025

Choose a reason for hiding this comment

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

I haven't seen this pattern used outside of ZJIT. There's nothing wrong with it, but I'm curious if it has any benefits over the more pedestrian:

if !args.is_empty() {
    return None;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's to keep the code ~parallel with other methods in the file where we do actually unpack things from the slice

@tekknolagi tekknolagi marked this pull request as ready for review November 21, 2025 16:02
@matzbot matzbot requested a review from a team November 21, 2025 16:02
@tekknolagi tekknolagi merged commit e5e8ac5 into ruby:master Nov 21, 2025
93 checks passed
@tekknolagi tekknolagi deleted the mb-specialize-string-empty-p branch November 21, 2025 16:48
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.

3 participants