Skip to content

Commit

Permalink
Apply const for const member.
Browse files Browse the repository at this point in the history
This pointer is never null, so it can be a reference.

PiperOrigin-RevId: 706749509
Change-Id: If21e4a47609b427e78e37754be32fa13903b4110
ckennelly authored and copybara-github committed Dec 16, 2024
1 parent e4308a4 commit bb33d08
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tcmalloc/span.h
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ class Span final : public SpanList::Elem {
// ensure by some other means that the sampling state can't be changed
// concurrently.
// REQUIRES: this is a SAMPLED span.
SampledAllocation* sampled_allocation() const;
const SampledAllocation& sampled_allocation() const;

// Is it a sampling span?
// For debug checks. pageheap_lock is not required, but caller needs to ensure
@@ -460,10 +460,10 @@ inline bool Span::BitmapPush(void* ptr, size_t size, uint32_t reciprocal) {
return true;
}

inline SampledAllocation* Span::sampled_allocation() const {
inline const SampledAllocation& Span::sampled_allocation() const {
TC_ASSERT(sampled_);
TC_ASSERT(is_large_or_sampled());
return large_or_sampled_state_.sampled_allocation;
return *large_or_sampled_state_.sampled_allocation;
}

inline bool Span::sampled() const { return sampled_; }
2 changes: 1 addition & 1 deletion tcmalloc/tcmalloc.cc
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ inline size_t GetLargeSize(const void* ptr, const Span& span) {
if (tc_globals.guardedpage_allocator().PointerIsMine(ptr)) {
return tc_globals.guardedpage_allocator().GetRequestedSize(ptr);
}
return span.sampled_allocation()->sampled_stack.allocated_size;
return span.sampled_allocation().sampled_stack.allocated_size;
} else {
return span.bytes_in_span();
}

0 comments on commit bb33d08

Please sign in to comment.