Skip to content

Commit ff8b2b5

Browse files
committed
Linting
1 parent cc1637f commit ff8b2b5

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

examples/arm/executor_runner/arm_executor_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <memory>
2020
#include <vector>
2121

22-
#include "arm_perf_monitor.h"
2322
#include "arm_memory_allocator.h"
23+
#include "arm_perf_monitor.h"
2424

2525
#if defined(ET_BUNDLE_IO)
2626
#include <executorch/devtools/bundled_program/bundled_program.h>

examples/arm/executor_runner/arm_memory_allocator.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,42 @@
77
#include "arm_memory_allocator.h"
88

99
ArmMemoryAllocator::ArmMemoryAllocator(uint32_t size, uint8_t* base_address)
10-
: MemoryAllocator(size, base_address), used_(0), peak_used_(0) {}
10+
: MemoryAllocator(size, base_address), used_(0), peak_used_(0) {}
1111

12-
void* ArmMemoryAllocator::allocate(size_t size, size_t alignment = kDefaultAlignment) override {
13-
void* ret = executorch::runtime::MemoryAllocator::allocate(size, alignment);
14-
if (ret != nullptr) {
15-
// Align with the same code as in MemoryAllocator::allocate() to keep
16-
// used_ "in sync" As alignment is expected to be power of 2 (checked by
17-
// MemoryAllocator::allocate()) we can check it the lower bits
18-
// (same as alignment - 1) is zero or not.
19-
if ((size & (alignment - 1)) == 0) {
20-
// Already aligned.
21-
used_ += size;
22-
} else {
23-
used_ = (used_ | (alignment - 1)) + 1 + size;
24-
}
25-
if (used_ > peak_used_)
26-
peak_used_ = used_;
12+
void* ArmMemoryAllocator::allocate(
13+
size_t size,
14+
size_t alignment = kDefaultAlignment) override {
15+
void* ret = executorch::runtime::MemoryAllocator::allocate(size, alignment);
16+
if (ret != nullptr) {
17+
// Align with the same code as in MemoryAllocator::allocate() to keep
18+
// used_ "in sync" As alignment is expected to be power of 2 (checked by
19+
// MemoryAllocator::allocate()) we can check it the lower bits
20+
// (same as alignment - 1) is zero or not.
21+
if ((size & (alignment - 1)) == 0) {
22+
// Already aligned.
23+
used_ += size;
24+
} else {
25+
used_ = (used_ | (alignment - 1)) + 1 + size;
2726
}
28-
return ret;
27+
if (used_ > peak_used_)
28+
peak_used_ = used_;
29+
}
30+
return ret;
2931
}
3032

3133
size_t ArmMemoryAllocator::used_size() const {
32-
return used_;
34+
return used_;
3335
}
3436

3537
size_t ArmMemoryAllocator::peak_used() const {
36-
return peak_used_;
38+
return peak_used_;
3739
}
3840

3941
size_t ArmMemoryAllocator::free_size() const {
40-
return executorch::runtime::MemoryAllocator::size() - used_;
42+
return executorch::runtime::MemoryAllocator::size() - used_;
4143
}
4244

4345
void ArmMemoryAllocator::reset() {
44-
executorch::runtime::MemoryAllocator::reset();
45-
used_ = 0;
46+
executorch::runtime::MemoryAllocator::reset();
47+
used_ = 0;
4648
}

examples/arm/executor_runner/arm_memory_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ class ArmMemoryAllocator : public executorch::runtime::MemoryAllocator {
3333
size_t used_;
3434
size_t peak_used_;
3535
};
36-

0 commit comments

Comments
 (0)