| 68 | } |
| 69 | |
| 70 | void ScopedTrace::pop() FL_NOEXCEPT { |
| 71 | auto& storage = getTraceStorage(); |
| 72 | |
| 73 | // Guard against underflow |
| 74 | if (storage.stackDepth == 0) { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | // Decrement depth counter first |
| 79 | storage.stackDepth--; |
| 80 | |
| 81 | // Pop from callStack only if: |
| 82 | // 1. We have entries in the stack |
| 83 | // 2. After decrement, depth matches or is less than callStack size |
| 84 | // (this handles both normal operation and overflow recovery) |
| 85 | if (!storage.callStack.empty() && storage.stackDepth < storage.callStack.size()) { |
| 86 | // Use manual pop since FixedVector doesn't have pop_back |
| 87 | storage.callStack.resize(storage.callStack.size() - 1); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | fl::size ScopedTrace::depth() FL_NOEXCEPT { |
| 92 | return getTraceStorage().stackDepth; |