Skip to content

Commit

Permalink
Use llvm::map_range() instead of using mapped_iterator directly (#4997)
Browse files Browse the repository at this point in the history
map_range() is a nice helper for constructing a pair of
mapped_iterators.
  • Loading branch information
danakj authored Feb 21, 2025
1 parent d843cc5 commit 210c26e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions toolchain/base/value_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ class ValueStore
auto [index, value] = pair;
return std::pair<IdT, ConstRefType>(IdT(index), value);
};
auto range = llvm::enumerate(values_);
using Iter =
llvm::mapped_iterator<decltype(range.begin()), decltype(index_to_id)>;
auto begin = Iter(range.begin(), index_to_id);
auto end = Iter(range.end(), index_to_id);
return llvm::make_range(begin, end);
return llvm::map_range(llvm::enumerate(values_), index_to_id);
}

private:
Expand Down
7 changes: 1 addition & 6 deletions toolchain/sem_ir/constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ class ConstantValueStore {
auto [index, value] = pair;
return std::pair<InstId, ConstantId>(InstId(index), value);
};
auto range = llvm::enumerate(values_);
using Iter =
llvm::mapped_iterator<decltype(range.begin()), decltype(index_to_id)>;
auto begin = Iter(range.begin(), index_to_id);
auto end = Iter(range.end(), index_to_id);
return llvm::make_range(begin, end);
return llvm::map_range(llvm::enumerate(values_), index_to_id);
}

// Returns the symbolic constants mapping as an ArrayRef whose keys are
Expand Down

0 comments on commit 210c26e

Please sign in to comment.