From 65059f2addbc7a39e93440eae6c541c4d2885ef1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 Nov 2017 12:43:09 +0100 Subject: [PATCH] util/{Const,Writable}Buffer: eliminate static method Null(), use nullptr cast instead --- src/decoder/plugins/ModplugDecoderPlugin.cxx | 4 ++-- src/util/AllocatedArray.hxx | 2 +- src/util/ConstBuffer.hxx | 8 -------- src/util/WritableBuffer.hxx | 8 -------- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/decoder/plugins/ModplugDecoderPlugin.cxx b/src/decoder/plugins/ModplugDecoderPlugin.cxx index 544c0b55c..5a7cccf17 100644 --- a/src/decoder/plugins/ModplugDecoderPlugin.cxx +++ b/src/decoder/plugins/ModplugDecoderPlugin.cxx @@ -66,12 +66,12 @@ mod_loadfile(DecoderClient *client, InputStream &is) if (size == 0) { LogWarning(modplug_domain, "file is empty"); - return { nullptr, 0 }; + return nullptr; } if (size > MODPLUG_FILE_LIMIT) { LogWarning(modplug_domain, "file too large"); - return { nullptr, 0 }; + return nullptr; } buffer.size = size; diff --git a/src/util/AllocatedArray.hxx b/src/util/AllocatedArray.hxx index c7d3b9b28..138134435 100644 --- a/src/util/AllocatedArray.hxx +++ b/src/util/AllocatedArray.hxx @@ -72,7 +72,7 @@ public: AllocatedArray(AllocatedArray &&other) :buffer(other.buffer) { - other.buffer = Buffer::Null(); + other.buffer = nullptr; } ~AllocatedArray() { diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx index 189837d3a..6c9df593b 100644 --- a/src/util/ConstBuffer.hxx +++ b/src/util/ConstBuffer.hxx @@ -60,10 +60,6 @@ struct ConstBuffer { constexpr ConstBuffer(pointer_type _data, size_type _size) :data(_data), size(_size) {} - constexpr static ConstBuffer Null() { - return ConstBuffer(nullptr, 0); - } - constexpr static ConstBuffer FromVoid(ConstBuffer other) { return other; } @@ -120,10 +116,6 @@ struct ConstBuffer { constexpr ConstBuffer(const T (&_data)[_size]) :data(_data), size(_size) {} - constexpr static ConstBuffer Null() { - return ConstBuffer(nullptr, 0); - } - /** * Cast a ConstBuffer to a ConstBuffer, rounding down * to the next multiple of T's size. diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx index b89fc83e5..a86ec50e5 100644 --- a/src/util/WritableBuffer.hxx +++ b/src/util/WritableBuffer.hxx @@ -60,10 +60,6 @@ struct WritableBuffer { constexpr WritableBuffer(pointer_type _data, size_type _size) :data(_data), size(_size) {} - constexpr static WritableBuffer Null() { - return { nullptr, 0 }; - } - constexpr bool IsNull() const { return data == nullptr; } @@ -114,10 +110,6 @@ struct WritableBuffer { constexpr WritableBuffer(T (&_data)[_size]) :data(_data), size(_size) {} - constexpr static WritableBuffer Null() { - return { nullptr, 0 }; - } - /** * Cast a WritableBuffer to a WritableBuffer, * rounding down to the next multiple of T's size.