refactor(Core): apply clang-tidy modernize-use-nodiscard (#3835)

This commit is contained in:
Francesco Borzì
2020-12-06 19:39:48 +01:00
committed by GitHub
parent d4a58700d4
commit 161302252e
82 changed files with 1565 additions and 1569 deletions

View File

@@ -53,27 +53,27 @@ public:
offset = r.offset;
return *this;
}
float getFloat(size_t field) const
[[nodiscard]] float getFloat(size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<float*>(offset + field * 4);
}
unsigned int getUInt(size_t field) const
[[nodiscard]] unsigned int getUInt(size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<unsigned int*>(offset + (field * 4));
}
int getInt(size_t field) const
[[nodiscard]] int getInt(size_t field) const
{
assert(field < file.fieldCount);
return *reinterpret_cast<int*>(offset + field * 4);
}
unsigned char getByte(size_t ofs) const
[[nodiscard]] unsigned char getByte(size_t ofs) const
{
assert(ofs < file.recordSize);
return *reinterpret_cast<unsigned char*>(offset + ofs);
}
const char* getString(size_t field) const
[[nodiscard]] const char* getString(size_t field) const
{
assert(field < file.fieldCount);
size_t stringOffset = getUInt(field);
@@ -129,8 +129,8 @@ public:
/// Get begin iterator over records
Iterator end();
/// Trivial
size_t getRecordCount() const { return recordCount;}
size_t getFieldCount() const { return fieldCount; }
[[nodiscard]] size_t getRecordCount() const { return recordCount;}
[[nodiscard]] size_t getFieldCount() const { return fieldCount; }
private:
std::string filename;

View File

@@ -85,12 +85,12 @@ public:
return *this;
}
float lengthSquared() const
[[nodiscard]] float lengthSquared() const
{
return x * x + y * y + z * z;
}
float length() const
[[nodiscard]] float length() const
{
return sqrt(x * x + y * y + z * z);
}
@@ -192,12 +192,12 @@ public:
return *this;
}
float lengthSquared() const
[[nodiscard]] float lengthSquared() const
{
return x * x + y * y;
}
float length() const
[[nodiscard]] float length() const
{
return sqrt(x * x + y * y);
}