Skip to content
Permalink
Browse files
Remove unnecessary WTF:: prefixes in CachedTypes
https://bugs.webkit.org/show_bug.cgi?id=194936

Reviewed by Saam Barati.

Cleanup unnecessary prefixes from Optional, roundUpToMultipleOf and
pageSize.

* runtime/CachedTypes.cpp:
(JSC::Encoder::cachedOffsetForPtr):
(JSC::Encoder::Page::malloc):
(JSC::Encoder::allocateNewPage):
(JSC::CachedPtr::encode):
(JSC::CachedPtr::decode const):
(JSC::CachedOptional::encode):
(JSC::CachedOptional::decode const):


Canonical link: https://commits.webkit.org/209377@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
tadeuzagallo committed Feb 25, 2019
1 parent 53d2ce5 commit cfb747551225884ee445affa5199d9f7890d9dd9
Showing 2 changed files with 31 additions and 12 deletions.
@@ -1,3 +1,22 @@
2019-02-25 Tadeu Zagallo <tzagallo@apple.com>

Remove unnecessary WTF:: prefixes in CachedTypes
https://bugs.webkit.org/show_bug.cgi?id=194936

Reviewed by Saam Barati.

Cleanup unnecessary prefixes from Optional, roundUpToMultipleOf and
pageSize.

* runtime/CachedTypes.cpp:
(JSC::Encoder::cachedOffsetForPtr):
(JSC::Encoder::Page::malloc):
(JSC::Encoder::allocateNewPage):
(JSC::CachedPtr::encode):
(JSC::CachedPtr::decode const):
(JSC::CachedOptional::encode):
(JSC::CachedOptional::decode const):

2019-02-25 Yusuke Suzuki <ysuzuki@apple.com>

[JSC] Drop direct references to Intl constructors by rewriting Intl JS builtins in C++
@@ -127,7 +127,7 @@ class Encoder {
m_ptrToOffsetMap.add(ptr, offset);
}

WTF::Optional<ptrdiff_t> cachedOffsetForPtr(const void* ptr)
Optional<ptrdiff_t> cachedOffsetForPtr(const void* ptr)
{
auto it = m_ptrToOffsetMap.find(ptr);
if (it == m_ptrToOffsetMap.end())
@@ -161,8 +161,8 @@ class Encoder {
bool malloc(size_t size, ptrdiff_t& result)
{
size_t alignment = std::min(alignof(std::max_align_t), static_cast<size_t>(WTF::roundUpToPowerOfTwo(size)));
ptrdiff_t offset = WTF::roundUpToMultipleOf(alignment, m_offset);
size = WTF::roundUpToMultipleOf(alignment, size);
ptrdiff_t offset = roundUpToMultipleOf(alignment, m_offset);
size = roundUpToMultipleOf(alignment, size);
if (static_cast<size_t>(offset + size) > m_capacity)
return false;

@@ -192,13 +192,13 @@ class Encoder {

void allocateNewPage(size_t size = 0)
{
static size_t minPageSize = WTF::pageSize();
static size_t minPageSize = pageSize();
if (m_currentPage)
m_baseOffset += m_currentPage->size();
if (size < minPageSize)
size = minPageSize;
else
size = WTF::roundUpToMultipleOf(minPageSize, size);
size = roundUpToMultipleOf(minPageSize, size);
m_pages.append(Page { size });
m_currentPage = &m_pages.last();
}
@@ -245,7 +245,7 @@ class Decoder {
m_offsetToPtrMap.add(offset, ptr);
}

WTF::Optional<void*> cachedPtrForOffset(ptrdiff_t offset)
Optional<void*> cachedPtrForOffset(ptrdiff_t offset)
{
auto it = m_offsetToPtrMap.find(offset);
if (it == m_offsetToPtrMap.end())
@@ -377,7 +377,7 @@ class CachedPtr : public VariableLengthObject<Source*> {
if (m_isEmpty)
return;

if (WTF::Optional<ptrdiff_t> offset = encoder.cachedOffsetForPtr(src)) {
if (Optional<ptrdiff_t> offset = encoder.cachedOffsetForPtr(src)) {
this->m_offset = *offset - encoder.offsetOf(&this->m_offset);
return;
}
@@ -396,7 +396,7 @@ class CachedPtr : public VariableLengthObject<Source*> {
}

ptrdiff_t bufferOffset = decoder.offsetOf(this->buffer());
if (WTF::Optional<void*> ptr = decoder.cachedPtrForOffset(bufferOffset)) {
if (Optional<void*> ptr = decoder.cachedPtrForOffset(bufferOffset)) {
isNewAllocation = false;
return reinterpret_cast<Source*>(*ptr);
}
@@ -689,9 +689,9 @@ class CachedIdentifier : public VariableLengthObject<Identifier> {
};

template<typename T>
class CachedOptional : public VariableLengthObject<WTF::Optional<SourceType<T>>> {
class CachedOptional : public VariableLengthObject<Optional<SourceType<T>>> {
public:
void encode(Encoder& encoder, const WTF::Optional<SourceType<T>>& source)
void encode(Encoder& encoder, const Optional<SourceType<T>>& source)
{
m_isEmpty = !source;

@@ -701,15 +701,15 @@ class CachedOptional : public VariableLengthObject<WTF::Optional<SourceType<T>>>
this->template allocate<T>(encoder)->encode(encoder, *source);
}

WTF::Optional<SourceType<T>> decode(Decoder& decoder) const
Optional<SourceType<T>> decode(Decoder& decoder) const
{
if (m_isEmpty)
return WTF::nullopt;

return { this->template buffer<T>()->decode(decoder) };
}

void decode(Decoder& decoder, WTF::Optional<SourceType<T>>& dst) const
void decode(Decoder& decoder, Optional<SourceType<T>>& dst) const
{
dst = decode(decoder);
}

0 comments on commit cfb7475

Please sign in to comment.