Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Nov 8, 2024
1 parent 982f88d commit 9e920e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
16 changes: 8 additions & 8 deletions benchmark/src/benchmarks/benchmark.stringpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace zasm::benchmarks
return strings;
}();

static void BM_StringPool_Aquire(benchmark::State& state)
static void BM_StringPool_Acquire(benchmark::State& state)
{
StringPool pool;
for (auto _ : state)
Expand All @@ -32,12 +32,12 @@ namespace zasm::benchmarks
{
const auto& str = kInputStrings[i];

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
benchmark::DoNotOptimize(stringId);
}
}
}
BENCHMARK(BM_StringPool_Aquire)->Range(0, kTestSize)->Unit(benchmark::kMillisecond);
BENCHMARK(BM_StringPool_Acquire)->Range(0, kTestSize)->Unit(benchmark::kMillisecond);

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

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
state.ResumeTiming();

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

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
stringIds.push_back(stringId);
}

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

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
benchmark::DoNotOptimize(stringId);
}
}
Expand All @@ -103,7 +103,7 @@ namespace zasm::benchmarks
state.PauseTiming();
const auto& str = kInputStrings[i];

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
state.ResumeTiming();

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

auto stringId = pool.aquire(str);
auto stringId = pool.acquire(str);
state.ResumeTiming();

auto strLen = pool.getLength(stringId);
Expand Down
20 changes: 10 additions & 10 deletions tests/src/tests/tests.stringpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace zasm::tests
constexpr const char str1[] = "hello";
constexpr const char str2[] = "Hello";

const auto id0 = pool.aquire(str1);
const auto id0 = pool.acquire(str1);
ASSERT_NE(id0, StringPool::Id::Invalid);
ASSERT_EQ(pool.getLength(id0), std::size(str1) - 1);
ASSERT_EQ(pool.getRefCount(id0), 1);
const auto* cstr0 = pool.get(id0);
ASSERT_NE(cstr0, nullptr);
ASSERT_EQ(strcmp(cstr0, str1), 0);

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

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

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

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

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

const auto id3 = pool.aquire(str4);
const auto id3 = pool.acquire(str4);
ASSERT_NE(id3, StringPool::Id::Invalid);
ASSERT_EQ(id1, id3);
ASSERT_EQ(pool.getLength(id3), std::size(str4) - 1);
ASSERT_EQ(pool.getRefCount(id3), 1);

const auto id4 = pool.aquire(str4);
const auto id4 = pool.acquire(str4);
ASSERT_NE(id4, StringPool::Id::Invalid);
ASSERT_EQ(id4, id3);
ASSERT_EQ(pool.getLength(id4), std::size(str4) - 1);
Expand All @@ -83,7 +83,7 @@ namespace zasm::tests
ASSERT_EQ(pool.release(id4), 1);
ASSERT_EQ(pool.release(id4), 0);

const auto id5 = pool.aquire(str5);
const auto id5 = pool.acquire(str5);
ASSERT_NE(id5, StringPool::Id::Invalid);
ASSERT_EQ(id5, id1);
ASSERT_EQ(pool.getLength(id5), std::size(str5) - 1);
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace zasm::tests
ids.clear();
for (const auto& str : kInputStrings)
{
const auto id = pool.aquire(str);
const auto id = pool.acquire(str);
ASSERT_NE(id, StringPool::Id::Invalid);
ASSERT_EQ(pool.getLength(id), str.size());
ASSERT_EQ(pool.getRefCount(id), 1);
Expand Down
11 changes: 8 additions & 3 deletions zasm/include/zasm/core/stringpool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace zasm
_hashBuckets.resize(kMaxHashBuckets);
}

Id aquire(const char* value, std::size_t size = kUnspecifiedSize)
Id acquire(const char* value, std::size_t size = kUnspecifiedSize)
{
if (size == kUnspecifiedSize)
{
Expand All @@ -84,12 +84,12 @@ namespace zasm
return aquire_(value, size);
}

Id aquire(std::string_view str)
Id acquire(std::string_view str)
{
return aquire_(str.data(), str.size());
}

Id aquire(const std::string& val)
Id acquire(const std::string& val)
{
return aquire_(val.c_str(), val.size());
}
Expand Down Expand Up @@ -167,6 +167,11 @@ namespace zasm

void clear() noexcept
{
if (_entries.empty())
{
// Because clearing the buckets is expensive do nothing if already empty.
return;
}
_entries.clear();
if (_blocks.size() > 1)
{
Expand Down
8 changes: 4 additions & 4 deletions zasm/src/zasm/src/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace zasm

if (name != nullptr)
{
entry.nameId = _state->symbolNames.aquire(name);
entry.nameId = _state->symbolNames.acquire(name);
}
}

Expand Down Expand Up @@ -594,7 +594,7 @@ namespace zasm
{
return StringPool::Id::Invalid;
}
return state.symbolNames.aquire(str);
return state.symbolNames.acquire(str);
}

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

if (name != nullptr)
{
entry.nameId = _state->symbolNames.aquire(name);
entry.nameId = _state->symbolNames.acquire(name);
}

return Section{ sectId };
Expand Down Expand Up @@ -800,7 +800,7 @@ namespace zasm
entry->nameId = StringPool::Id::Invalid;
}

entry->nameId = _state->symbolNames.aquire(name);
entry->nameId = _state->symbolNames.acquire(name);
return ErrorCode::None;
}

Expand Down
2 changes: 1 addition & 1 deletion zasm/src/zasm/src/serialization/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ namespace zasm
defaultSect.attribs = Section::kDefaultAttribs;
defaultSect.align = Section::kDefaultAlign;
defaultSect.address = newBase;
defaultSect.nameId = programState.symbolNames.aquire(".text");
defaultSect.nameId = programState.symbolNames.acquire(".text");

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

0 comments on commit 9e920e0

Please sign in to comment.