Skip to content

Commit

Permalink
Make improvements suggested by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Apr 16, 2024
1 parent d7a129d commit e4765f9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/include/FlashString/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ template <class ObjectType, typename ElementType> class Object : public ObjectBa
{
}

~Object()
{
}

Object(const Object&& obj) = delete;
Object& operator=(const Object& other) = delete;
Object& operator=(const Object&& other) = delete;

Iterator begin() const
{
return Iterator(as<ObjectType>(), 0);
Expand Down Expand Up @@ -177,7 +185,7 @@ template <class ObjectType, typename ElementType> class Object : public ObjectBa
auto len = self.length();
for(unsigned i = 0; i < len; ++i) {
if(self.unsafeValueAt(dataptr, i) == value) {
return i;
return int(i);
}
}

Expand All @@ -204,6 +212,7 @@ template <class ObjectType, typename ElementType> class Object : public ObjectBa

FSTR_INLINE DataPtrType data() const
{
// NOLINTNEXTLINE
return reinterpret_cast<DataPtrType>(ObjectBase::data());
}

Expand Down
1 change: 1 addition & 0 deletions src/include/FlashString/ObjectBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ObjectBase
return 0;
}
if(isCopy()) {
// NOLINTNEXTLINE
return reinterpret_cast<const ObjectBase*>(flashLength_ & ~copyBit)->length();
}
return flashLength_;
Expand Down
13 changes: 10 additions & 3 deletions src/include/FlashString/ObjectIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ template <class ObjectType, typename ElementType> class ObjectIterator

ObjectIterator() = default;
ObjectIterator(const ObjectIterator&) = default;
ObjectIterator(ObjectIterator&&) = default;
ObjectIterator& operator=(const ObjectIterator&) = default;
ObjectIterator& operator=(ObjectIterator&&) = default;

ObjectIterator(const ObjectType& object, unsigned index)
: data(pointer(object.data())), length(object.length()), index(index)
{
}

~ObjectIterator()
{
}

ObjectIterator& operator++()
{
++index;
Expand Down Expand Up @@ -93,9 +100,9 @@ template <class ObjectType, typename ElementType> class ObjectIterator
}

private:
const pointer data;
size_t length;
unsigned index = 0;
pointer data{};
size_t length{0};
unsigned index{0};
};

} // namespace FSTR
1 change: 1 addition & 0 deletions src/include/FlashString/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class String : public Object<String, char>
*/
flash_string_t data() const
{
// NOLINTNEXTLINE
return reinterpret_cast<flash_string_t>(Object::data());
}

Expand Down
9 changes: 9 additions & 0 deletions src/include/FlashString/StringPrinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ class StringPrinter
{
}

StringPrinter(const StringPrinter&) = delete;
StringPrinter(StringPrinter&&) = delete;
StringPrinter& operator=(const StringPrinter&) = delete;
StringPrinter& operator=(StringPrinter&&) = delete;

~StringPrinter()
{
}

size_t printTo(Print& p) const;

private:
Expand Down

0 comments on commit e4765f9

Please sign in to comment.