Skip to content

Commit 9e920e0

Browse files
committed
Fix typo
1 parent 982f88d commit 9e920e0

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

benchmark/src/benchmarks/benchmark.stringpool.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace zasm::benchmarks
2323
return strings;
2424
}();
2525

26-
static void BM_StringPool_Aquire(benchmark::State& state)
26+
static void BM_StringPool_Acquire(benchmark::State& state)
2727
{
2828
StringPool pool;
2929
for (auto _ : state)
@@ -32,12 +32,12 @@ namespace zasm::benchmarks
3232
{
3333
const auto& str = kInputStrings[i];
3434

35-
auto stringId = pool.aquire(str);
35+
auto stringId = pool.acquire(str);
3636
benchmark::DoNotOptimize(stringId);
3737
}
3838
}
3939
}
40-
BENCHMARK(BM_StringPool_Aquire)->Range(0, kTestSize)->Unit(benchmark::kMillisecond);
40+
BENCHMARK(BM_StringPool_Acquire)->Range(0, kTestSize)->Unit(benchmark::kMillisecond);
4141

4242
static void BM_StringPool_Release(benchmark::State& state)
4343
{
@@ -49,7 +49,7 @@ namespace zasm::benchmarks
4949
state.PauseTiming();
5050
const auto& str = kInputStrings[i];
5151

52-
auto stringId = pool.aquire(str);
52+
auto stringId = pool.acquire(str);
5353
state.ResumeTiming();
5454

5555
auto refCount = pool.release(stringId);
@@ -71,7 +71,7 @@ namespace zasm::benchmarks
7171
{
7272
const auto& str = kInputStrings[i];
7373

74-
auto stringId = pool.aquire(str);
74+
auto stringId = pool.acquire(str);
7575
stringIds.push_back(stringId);
7676
}
7777

@@ -86,7 +86,7 @@ namespace zasm::benchmarks
8686
{
8787
const auto& str = kInputStrings[i];
8888

89-
auto stringId = pool.aquire(str);
89+
auto stringId = pool.acquire(str);
9090
benchmark::DoNotOptimize(stringId);
9191
}
9292
}
@@ -103,7 +103,7 @@ namespace zasm::benchmarks
103103
state.PauseTiming();
104104
const auto& str = kInputStrings[i];
105105

106-
auto stringId = pool.aquire(str);
106+
auto stringId = pool.acquire(str);
107107
state.ResumeTiming();
108108

109109
const char* res = pool.get(stringId);
@@ -123,7 +123,7 @@ namespace zasm::benchmarks
123123
state.PauseTiming();
124124
const auto& str = kInputStrings[i];
125125

126-
auto stringId = pool.aquire(str);
126+
auto stringId = pool.acquire(str);
127127
state.ResumeTiming();
128128

129129
auto strLen = pool.getLength(stringId);

tests/src/tests/tests.stringpool.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ namespace zasm::tests
1313
constexpr const char str1[] = "hello";
1414
constexpr const char str2[] = "Hello";
1515

16-
const auto id0 = pool.aquire(str1);
16+
const auto id0 = pool.acquire(str1);
1717
ASSERT_NE(id0, StringPool::Id::Invalid);
1818
ASSERT_EQ(pool.getLength(id0), std::size(str1) - 1);
1919
ASSERT_EQ(pool.getRefCount(id0), 1);
2020
const auto* cstr0 = pool.get(id0);
2121
ASSERT_NE(cstr0, nullptr);
2222
ASSERT_EQ(strcmp(cstr0, str1), 0);
2323

24-
const auto id1 = pool.aquire(str1);
24+
const auto id1 = pool.acquire(str1);
2525
ASSERT_NE(id1, StringPool::Id::Invalid);
2626
ASSERT_EQ(id1, id0);
2727
ASSERT_EQ(pool.getLength(id1), std::size(str1) - 1);
@@ -30,7 +30,7 @@ namespace zasm::tests
3030
ASSERT_EQ(cstr1, cstr0);
3131
ASSERT_EQ(strcmp(cstr1, str1), 0);
3232

33-
const auto id2 = pool.aquire(str2);
33+
const auto id2 = pool.acquire(str2);
3434
ASSERT_NE(id2, StringPool::Id::Invalid);
3535
ASSERT_NE(id2, id1);
3636
ASSERT_EQ(pool.getLength(id2), std::size(str2) - 1);
@@ -49,17 +49,17 @@ namespace zasm::tests
4949
constexpr const char str4[] = "hello4";
5050
constexpr const char str5[] = "hello...";
5151

52-
const auto id0 = pool.aquire(str1);
52+
const auto id0 = pool.acquire(str1);
5353
ASSERT_NE(id0, StringPool::Id::Invalid);
5454
ASSERT_EQ(pool.getLength(id0), std::size(str1) - 1);
5555
ASSERT_EQ(pool.getRefCount(id0), 1);
5656

57-
const auto id1 = pool.aquire(str2);
57+
const auto id1 = pool.acquire(str2);
5858
ASSERT_NE(id1, StringPool::Id::Invalid);
5959
ASSERT_EQ(pool.getLength(id1), std::size(str2) - 1);
6060
ASSERT_EQ(pool.getRefCount(id1), 1);
6161

62-
const auto id2 = pool.aquire(str3);
62+
const auto id2 = pool.acquire(str3);
6363
ASSERT_NE(id2, StringPool::Id::Invalid);
6464
ASSERT_EQ(pool.getLength(id2), std::size(str3) - 1);
6565
ASSERT_EQ(pool.getRefCount(id2), 1);
@@ -68,13 +68,13 @@ namespace zasm::tests
6868
const auto* cstr0 = pool.get(id1);
6969
ASSERT_EQ(cstr0, nullptr);
7070

71-
const auto id3 = pool.aquire(str4);
71+
const auto id3 = pool.acquire(str4);
7272
ASSERT_NE(id3, StringPool::Id::Invalid);
7373
ASSERT_EQ(id1, id3);
7474
ASSERT_EQ(pool.getLength(id3), std::size(str4) - 1);
7575
ASSERT_EQ(pool.getRefCount(id3), 1);
7676

77-
const auto id4 = pool.aquire(str4);
77+
const auto id4 = pool.acquire(str4);
7878
ASSERT_NE(id4, StringPool::Id::Invalid);
7979
ASSERT_EQ(id4, id3);
8080
ASSERT_EQ(pool.getLength(id4), std::size(str4) - 1);
@@ -83,7 +83,7 @@ namespace zasm::tests
8383
ASSERT_EQ(pool.release(id4), 1);
8484
ASSERT_EQ(pool.release(id4), 0);
8585

86-
const auto id5 = pool.aquire(str5);
86+
const auto id5 = pool.acquire(str5);
8787
ASSERT_NE(id5, StringPool::Id::Invalid);
8888
ASSERT_EQ(id5, id1);
8989
ASSERT_EQ(pool.getLength(id5), std::size(str5) - 1);
@@ -115,7 +115,7 @@ namespace zasm::tests
115115
ids.clear();
116116
for (const auto& str : kInputStrings)
117117
{
118-
const auto id = pool.aquire(str);
118+
const auto id = pool.acquire(str);
119119
ASSERT_NE(id, StringPool::Id::Invalid);
120120
ASSERT_EQ(pool.getLength(id), str.size());
121121
ASSERT_EQ(pool.getRefCount(id), 1);

zasm/include/zasm/core/stringpool.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace zasm
7575
_hashBuckets.resize(kMaxHashBuckets);
7676
}
7777

78-
Id aquire(const char* value, std::size_t size = kUnspecifiedSize)
78+
Id acquire(const char* value, std::size_t size = kUnspecifiedSize)
7979
{
8080
if (size == kUnspecifiedSize)
8181
{
@@ -84,12 +84,12 @@ namespace zasm
8484
return aquire_(value, size);
8585
}
8686

87-
Id aquire(std::string_view str)
87+
Id acquire(std::string_view str)
8888
{
8989
return aquire_(str.data(), str.size());
9090
}
9191

92-
Id aquire(const std::string& val)
92+
Id acquire(const std::string& val)
9393
{
9494
return aquire_(val.c_str(), val.size());
9595
}
@@ -167,6 +167,11 @@ namespace zasm
167167

168168
void clear() noexcept
169169
{
170+
if (_entries.empty())
171+
{
172+
// Because clearing the buckets is expensive do nothing if already empty.
173+
return;
174+
}
170175
_entries.clear();
171176
if (_blocks.size() > 1)
172177
{

zasm/src/zasm/src/program/program.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ namespace zasm
154154

155155
if (name != nullptr)
156156
{
157-
entry.nameId = _state->symbolNames.aquire(name);
157+
entry.nameId = _state->symbolNames.acquire(name);
158158
}
159159
}
160160

@@ -594,7 +594,7 @@ namespace zasm
594594
{
595595
return StringPool::Id::Invalid;
596596
}
597-
return state.symbolNames.aquire(str);
597+
return state.symbolNames.acquire(str);
598598
}
599599

600600
static Label createLabel_(detail::ProgramState& state, StringPool::Id nameId, StringPool::Id modId, LabelFlags flags)
@@ -731,7 +731,7 @@ namespace zasm
731731

732732
if (name != nullptr)
733733
{
734-
entry.nameId = _state->symbolNames.aquire(name);
734+
entry.nameId = _state->symbolNames.acquire(name);
735735
}
736736

737737
return Section{ sectId };
@@ -800,7 +800,7 @@ namespace zasm
800800
entry->nameId = StringPool::Id::Invalid;
801801
}
802802

803-
entry->nameId = _state->symbolNames.aquire(name);
803+
entry->nameId = _state->symbolNames.acquire(name);
804804
return ErrorCode::None;
805805
}
806806

zasm/src/zasm/src/serialization/serializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ namespace zasm
475475
defaultSect.attribs = Section::kDefaultAttribs;
476476
defaultSect.align = Section::kDefaultAlign;
477477
defaultSect.address = newBase;
478-
defaultSect.nameId = programState.symbolNames.aquire(".text");
478+
defaultSect.nameId = programState.symbolNames.acquire(".text");
479479

480480
const auto serializePass = [&]() -> Error {
481481
state.buffer.clear();

0 commit comments

Comments
 (0)