Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pointcloud_preprocessor): fix preprocessorErrorDirective #7786

Merged
merged 14 commits into from
Jul 4, 2024
69 changes: 4 additions & 65 deletions sensing/pointcloud_preprocessor/src/downsample_filter/robin_hood.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2021 Martin Ankerl <http://martin.ankerl.com>

Check notice on line 1 in sensing/pointcloud_preprocessor/src/downsample_filter/robin_hood.h

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 1452 to 1409, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in sensing/pointcloud_preprocessor/src/downsample_filter/robin_hood.h

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Number of Functions in a Single Module

The number of functions decreases from 186 to 180, threshold = 75. This file contains too many functions. Beyond a certain threshold, more functions lower the code health.
// ______ _____ ______ _________
// ______________ ___ /_ ___(_)_______ ___ /_ ______ ______ ______ /
// __ ___/_ __ \__ __ \__ / __ __ \ __ __ \_ __ \_ __ \_ __ /
Expand Down Expand Up @@ -126,10 +126,8 @@
// bitness
#if SIZE_MAX == UINT32_MAX
#define ROBIN_HOOD_PRIVATE_DEFINITION_BITNESS() 32
#elif SIZE_MAX == UINT64_MAX
#define ROBIN_HOOD_PRIVATE_DEFINITION_BITNESS() 64
#else
#error Unsupported bitness
#define ROBIN_HOOD_PRIVATE_DEFINITION_BITNESS() 64
#endif

// endianess
Expand Down Expand Up @@ -168,9 +166,9 @@
#define ROBIN_HOOD_COUNT_TRAILING_ZEROES(x) \
[](size_t mask) noexcept -> int { \
unsigned long index; \ // NOLINT
return ROBIN_HOOD(BITSCANFORWARD)(&index, mask) ? static_cast<int>(index) \
: ROBIN_HOOD(BITNESS); \
return ROBIN_HOOD(BITSCANFORWARD)(&index, mask) ? static_cast<int>(index) \ // cppcheck-suppress syntaxError
: ROBIN_HOOD(BITNESS); \ // cppcheck-suppress syntaxError
}(x)

Check failure on line 171 in sensing/pointcloud_preprocessor/src/downsample_filter/robin_hood.h

View workflow job for this annotation

GitHub Actions / cppcheck-differential

Unmatched '}'. Configuration: '_MSC_VER'. [syntaxError]

Check failure on line 171 in sensing/pointcloud_preprocessor/src/downsample_filter/robin_hood.h

View workflow job for this annotation

GitHub Actions / cppcheck-differential

Unmatched '}'. Configuration: '_MSC_VER;_NATIVE_WCHAR_T_DEFINED'. [syntaxError]
#else
#if ROBIN_HOOD(BITNESS) == 32
#define ROBIN_HOOD_PRIVATE_DEFINITION_CTZ() __builtin_ctzl
Expand Down Expand Up @@ -429,14 +427,6 @@
return *this;
}

BulkPoolAllocator &
// NOLINTNEXTLINE (bugprone-unhandled-self-assignment,cert-oop54-cpp)
operator=(const BulkPoolAllocator & ROBIN_HOOD_UNUSED(o) /*unused*/) noexcept
{
// does not do anything
return *this;
}

~BulkPoolAllocator() noexcept { reset(); }

// Deallocates all allocated memory.
Expand Down Expand Up @@ -475,22 +465,6 @@
mHead = obj;
}

// Adds an already allocated block of memory to the allocator. This allocator is from now on
// responsible for freeing the data (with free()). If the provided data is not large enough to
// make use of, it is immediately freed. Otherwise it is reused and freed in the destructor.
void addOrFree(void * ptr, const size_t numBytes) noexcept
{
// calculate number of available elements in ptr
if (numBytes < ALIGNMENT + ALIGNED_SIZE) {
// not enough data for at least one element. Free and return.
ROBIN_HOOD_LOG("std::free")
std::free(ptr);
} else {
ROBIN_HOOD_LOG("add to buffer")
add(ptr, numBytes);
}
}

void swap(BulkPoolAllocator<T, MinNumAllocs, MaxNumAllocs> & other) noexcept
{
using std::swap;
Expand Down Expand Up @@ -1382,7 +1356,7 @@
Iter & operator++() noexcept
{
mInfo++;
mKeyVals++;
++mKeyVals;
fastForward();
return *this;
}
Expand Down Expand Up @@ -2035,41 +2009,6 @@
return emplace(std::move(keyval)).first;
}

// Returns 1 if key is found, 0 otherwise.
size_t count(const key_type & key) const
{ // NOLINT (modernize-use-nodiscard)
ROBIN_HOOD_TRACE(this)
auto kv = mKeyVals + findIdx(key);
if (kv != reinterpret_cast_no_cast_align_warning<Node *>(mInfo)) {
return 1;
}
return 0;
}

template <typename OtherKey, typename Self_ = Self>
// NOLINTNEXTLINE (modernize-use-nodiscard)
typename std::enable_if<Self_::is_transparent, size_t>::type count(const OtherKey & key) const
{
ROBIN_HOOD_TRACE(this)
auto kv = mKeyVals + findIdx(key);
if (kv != reinterpret_cast_no_cast_align_warning<Node *>(mInfo)) {
return 1;
}
return 0;
}

bool contains(const key_type & key) const
{ // NOLINT (modernize-use-nodiscard)
return 1U == count(key);
}

template <typename OtherKey, typename Self_ = Self>
// NOLINTNEXTLINE (modernize-use-nodiscard)
typename std::enable_if<Self_::is_transparent, bool>::type contains(const OtherKey & key) const
{
return 1U == count(key);
}

// Returns a reference to the value found for key.
// Throws std::out_of_range if element cannot be found
template <typename Q = mapped_type>
Expand Down
Loading