Skip to content

is_char_boundary not elided when impl pop in terms of truncate #139655

Open
@Rudxain

Description

@Rudxain

I've implemented String::pop by using String::truncate internally. The UTF-8 boundary assertion check is still included in the release binary (for x86 targets). I can reproduce the lack of optimization on both 1.88.0-nightly (2025-04-07 e643f59) and stable (1.86.0)

Playground

I haven't tested if both functions are semantically-identical, but I've read the source-code (and docs) of both pop and truncate, so I am confident that pop_trunc is correct

@rustbot label: +I-slow

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions