Skip to content

Commit

Permalink
Fixed warnings introduced by recent PRs (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
snej authored Oct 10, 2024
1 parent 170d717 commit 75f7571
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
3 changes: 0 additions & 3 deletions API/fleece/Fleece.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace fleece {
class Value {
public:
Value() =default;
Value(const Value &) noexcept =default;
Value(FLValue FL_NULLABLE v) :_val(v) { }
operator FLValue FL_NULLABLE () const {return _val;}

Expand Down Expand Up @@ -116,7 +115,6 @@ namespace fleece {
public:
Array() :Value() { }
Array(FLArray FL_NULLABLE a) :Value((FLValue)a) { }
Array(const Array&) noexcept = default;
operator FLArray FL_NULLABLE () const {return (FLArray)_val;}

static Array emptyArray() {return Array(kFLEmptyArray);}
Expand Down Expand Up @@ -169,7 +167,6 @@ namespace fleece {
public:
Dict() :Value() { }
Dict(FLDict FL_NULLABLE d) :Value((FLValue)d) { }
Dict(const Dict&) noexcept = default;
operator FLDict FL_NULLABLE () const {return (FLDict)_val;}

static Dict emptyDict() {return Dict(kFLEmptyDict);}
Expand Down
12 changes: 6 additions & 6 deletions API/fleece/slice.hh
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ namespace fleece {
# endif
#endif

constexpr pure_slice(const pure_slice &s) noexcept = default;
constexpr pure_slice(std::nullptr_t) noexcept :pure_slice() {}
constexpr pure_slice(const char* FL_NULLABLE str) noexcept :buf(str), size(_strlen(str)) {}
pure_slice(const std::string& str LIFETIMEBOUND) noexcept :buf(str.data()), size(str.size()) {}
constexpr pure_slice(std::string_view str) noexcept :pure_slice(str.data(), str.length()) {}
constexpr pure_slice(std::string_view str) noexcept :buf(str.data()), size(str.size()) {}

// Raw memory allocation. These throw std::bad_alloc on failure.
RETURNS_NONNULL inline static void* newBytes(size_t sz);
Expand Down Expand Up @@ -568,7 +569,7 @@ namespace fleece {


inline std::string pure_slice::hexString() const {
static const char kDigits[17] = "0123456789abcdef";
static constexpr char kDigits[17] = "0123456789abcdef";
std::string result;
result.reserve(2 * size);
for (size_t i = 0; i < size; i++) {
Expand Down Expand Up @@ -747,8 +748,7 @@ namespace fleece {


inline void slice::setStart(const void *s) noexcept {
check(s);
set(s, pointerDiff(end(), s));
set(check(s), pointerDiff(end(), s));
}


Expand Down Expand Up @@ -848,10 +848,10 @@ namespace std {
// Declare the default hash function for `slice` and `alloc_slice`. This allows them to be
// used in hashed collections like `std::unordered_map` and `std::unordered_set`.
template<> struct hash<fleece::slice> {
std::size_t operator() (fleece::pure_slice const& s) const {return s.hash();}
std::size_t operator() (fleece::pure_slice const& s) const noexcept {return s.hash();}
};
template<> struct hash<fleece::alloc_slice> {
std::size_t operator() (fleece::pure_slice const& s) const {return s.hash();}
std::size_t operator() (fleece::pure_slice const& s) const noexcept {return s.hash();}
};
}

Expand Down
7 changes: 5 additions & 2 deletions Fleece/API_Impl/FLEncoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
#include "Fleece+ImplGlue.hh"
#include "Builder.hh"

#define ENCODER_DO(E, METHOD) (E)->do_([&](auto& e) {return e.METHOD;})
using namespace fleece;
using namespace fleece::impl;

#define ENCODER_TRY(E, METHOD) return (E)->try_([&](auto e) { ENCODER_DO(e, METHOD); return true;})
#define ENCODER_DO(E, METHOD) (E)->do_([&](auto& _e1) {return _e1.METHOD;})

#define ENCODER_TRY(E, METHOD) return (E)->try_([&](auto _e2) { ENCODER_DO(_e2, METHOD); return true;})

FLEncoder FLEncoder_New(void) FLAPI {
return FLEncoder_NewWithOptions(kFLEncodeFleece, 0, true);
Expand Down
4 changes: 0 additions & 4 deletions Fleece/API_Impl/Fleece+ImplGlue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#include <memory>
#include <variant>

using namespace fleece;
using namespace fleece::impl;


namespace fleece::impl {
class FLEncoderImpl;
}
Expand Down
4 changes: 2 additions & 2 deletions Fleece/Core/Builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace fleece::impl::builder {
protected:
// Parses a Fleece value from the input and stores it in the ValueSlot.
// Recognizes a '%' specifier, and calls `putParameter` to read the value from the args.
const bool _buildValue(ValueSlot &inSlot) {
bool _buildValue(ValueSlot &inSlot) {
switch (peekValue()) {
case ValueType::array: {
Retained<MutableArray> array = MutableArray::newArray();
Expand Down Expand Up @@ -207,7 +207,7 @@ namespace fleece::impl::builder {
protected:
// Parses a Fleece value from the input and writes it, prefixed by the key if one's given.
// Recognizes a '%' specifier, and calls `writeParameter` to read the value from the args.
const bool writeValue(slice key = nullslice) {
bool writeValue(slice key = nullslice) {
auto v = peekValue();
if (v != ValueType::arg && key)
_encoder.writeKey(key);
Expand Down
4 changes: 2 additions & 2 deletions Fleece/Support/JSONEncoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ namespace fleece { namespace impl {
void writeRaw(slice raw) {_out << raw;}

#ifdef __APPLE__
void writeCF(const void*) {FleeceException::_throw(JSONError,
[[noreturn]] void writeCF(const void*) {FleeceException::_throw(JSONError,
"Encoding CF value to JSON is unimplemented");}
#endif
#ifdef __OBJC__
void writeObjC(id) {FleeceException::_throw(JSONError,
[[noreturn]] void writeObjC(id) {FleeceException::_throw(JSONError,
"Encoding Obj-C to JSON is unimplemented");}
#endif

Expand Down

0 comments on commit 75f7571

Please sign in to comment.