This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Simplify single-iterator __bit_iterator algorithm specializations
ClosedPublic

Authored by philnik on Jul 22 2023, 12:18 PM.

Details

Summary

The single-iterator algorithms have an implementation for false and true, which are almost identical. Instead of writing two functions, this refactors the code to take the value searched for as a template parameter. This avoids a lot of code duplication and makes it easier to reason about the algorithm and their difference.

Diff Detail

Event Timeline

philnik created this revision.Jul 22 2023, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2023, 12:18 PM
philnik requested review of this revision.Jul 22 2023, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2023, 12:18 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Can you add a bit more information regarding the patch in the commit message?

libcxx/include/__bit_reference
184–188

Please use the LLVM coding standard.

philnik updated this revision to Diff 543326.Jul 23 2023, 2:05 PM
philnik marked an inline comment as done.

Address comments

philnik edited the summary of this revision. (Show Details)Jul 23 2023, 2:07 PM
Mordante accepted this revision.Jul 26 2023, 9:20 AM

LGTM!

This revision is now accepted and ready to land.Jul 26 2023, 9:20 AM