From b87a3ae7d35601deeac9156654148ada72026157 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 12 Dec 2024 11:54:57 -0500 Subject: [PATCH] Throughput cleanup + reenable nodiscard (#230) --- .clang-tidy | 1 - cpp/Ice/throughput/StringView.h | 106 ------------------------------ cpp/Ice/throughput/Throughput.ice | 6 +- 3 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 cpp/Ice/throughput/StringView.h diff --git a/.clang-tidy b/.clang-tidy index 32bcfb0a5..bc8c98b05 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,6 @@ Checks: cert-*, modernize-*, -modernize-avoid-c-arrays, - -modernize-use-nodiscard, -modernize-use-trailing-return-type, performance-*, -performance-avoid-endl diff --git a/cpp/Ice/throughput/StringView.h b/cpp/Ice/throughput/StringView.h deleted file mode 100644 index cac260c72..000000000 --- a/cpp/Ice/throughput/StringView.h +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef STRING_VIEW_H -#define STRING_VIEW_H - -#include - -namespace Util -{ - - // - // A simplified placeholder for std::string_view - // http://en.cppreference.com/w/cpp/string/basic_string_view - // - - class string_view - { - public: - constexpr string_view() = default; - constexpr string_view(const string_view&) = default; - - constexpr string_view(const char* str, size_t len) : _data(str), _size(len) {} - - string_view(const char* str) : _data(str), _size(strlen(str)) {} - - string_view& operator=(const string_view&) = default; - - constexpr size_t size() const { return _size; } - - constexpr size_t length() const { return _size; } - - constexpr bool empty() const { return _size != 0; } - - constexpr const char* data() const { return _data; } - - int compare(string_view str) const - { - if (_size == str._size) - { - if (_data == str._data) - { - return 0; - } - else - { - return strncmp(_data, str._data, _size); - } - } - else if (_size < str._size) - { - return -1; - } - else - { - return 1; - } - } - - private: - const char* _data = nullptr; - size_t _size = 0; - }; - - inline bool operator==(string_view lhs, string_view rhs) { return lhs.compare(rhs) == 0; } - - inline bool operator!=(string_view lhs, string_view rhs) { return lhs.compare(rhs) != 0; } - -} - -namespace Ice -{ - - // - // Describes how to marshal/unmarshal a Util::string_view - // It would be the same for a std::string_view - // - - template<> struct StreamableTraits - { - static const StreamHelperCategory helper = StreamHelperCategoryBuiltin; - static const int minWireSize = 1; - static const bool fixedLength = false; - }; - - template<> struct StreamHelper - { - template static inline void write(S* stream, const Util::string_view& v) - { - stream->write(v.data(), v.size()); - } - - template static inline void read(S* stream, Util::string_view& v) - { - const char* vdata = nullptr; - size_t vsize = 0; - - stream->read(vdata, vsize); - v = Util::string_view(vdata, vsize); - } - }; - -} - -#endif diff --git a/cpp/Ice/throughput/Throughput.ice b/cpp/Ice/throughput/Throughput.ice index 431f749f6..f41fed02f 100644 --- a/cpp/Ice/throughput/Throughput.ice +++ b/cpp/Ice/throughput/Throughput.ice @@ -1,11 +1,7 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// +// Copyright (c) ZeroC, Inc. #pragma once -[["cpp:include:StringView.h"]] - module Demo { sequence ByteSeq;