[PATCH] D143184: [MemProf] Add helper to access the back (last) call stack id
Snehasish Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 08:52:56 PST 2023
snehasish accepted this revision.
snehasish added a comment.
This revision is now accepted and ready to land.
lgtm
================
Comment at: llvm/include/llvm/Analysis/MemoryProfileInfo.h:141
: N(N) {
- if (!N)
- return;
- Iter = End ? N->StackIdIndices.end() : N->StackIdIndices.begin();
+ Iter =
+ N ? (End ? N->StackIdIndices.end() : N->StackIdIndices.begin()) : nullptr;
----------------
nit: I prefer the prior version with an early check since it's easier to read than a nested ternary.
```
if (!N) {
Iter = nullptr;
return;
}
Iter = End ? N->StackIdIndices.end() : N->StackIdIndices.begin();
```
Also writing it out made it clear that the change in this diff is ensuring that Iter is initialized to nullptr.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143184/new/
https://reviews.llvm.org/D143184
More information about the llvm-commits
mailing list