hsivonen / hsivonen/encoding_rs

Experiment with removing unsafe slice indexing

Open
#135 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
464
Forks
70
Avg merge
2d 4h
Merged PRs (30d)
2

Description

Back when I made some slice indexing use unsafe, the compiler wasn't able to elide the bound checks on its own. However, when I made utf8_iter and pasted code into Compiler Explorer, I noticed that the compiler had learned to elide the bound checks.

Experiment with which instances of unsafe manual bound check elision would now work as safe code without a performance penalty.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the unsafe manual bound-check elision sites, using the utf8_iter example and Compiler Explorer to compare generated code. Experiment with replacing eligible unsafe indexing with safe code, and consider the work done when the applicable instances retain performance without unnecessary unsafe code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.