Skip to content

Commit

Permalink
Rename mutable accessor in InstBlock store. (#4659)
Browse files Browse the repository at this point in the history
Mutating a block is a strange and rare operation and shouldn't have an
innocuous name like `Get`.
  • Loading branch information
zygoloid authored Dec 10, 2024
1 parent eabe9f1 commit d81ed4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions toolchain/sem_ir/block_value_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class BlockValueStore : public Yaml::Printable<BlockValueStore<IdT>> {
return values_.Get(id);
}

// Returns the requested block.
auto Get(IdT id) -> llvm::MutableArrayRef<ElementType> {
// Returns a mutable view of the requested block. This operation should be
// avoided where possible; we generally want blocks to be immutable once
// created.
auto GetMutable(IdT id) -> llvm::MutableArrayRef<ElementType> {
return values_.Get(id);
}

Expand Down
2 changes: 1 addition & 1 deletion toolchain/sem_ir/copy_on_write_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CopyOnWriteBlock {
if (id_ == source_id_) {
id_ = (file_.*ValueStore)().Add((file_.*ValueStore)().Get(source_id_));
}
(file_.*ValueStore)().Get(id_)[i] = value;
(file_.*ValueStore)().GetMutable(id_)[i] = value;
}

private:
Expand Down

0 comments on commit d81ed4b

Please sign in to comment.