diff --git a/arangod/Aql/TraversalNode.cpp b/arangod/Aql/TraversalNode.cpp index 2db9c8ad47..81fdc2eb8a 100644 --- a/arangod/Aql/TraversalNode.cpp +++ b/arangod/Aql/TraversalNode.cpp @@ -272,7 +272,7 @@ TraversalNode::TraversalNode(ExecutionPlan* plan, size_t id, _graphJson = arangodb::basics::Json(arangodb::basics::Json::Array, edgeColls.size()); for (auto& it : edgeColls) { - _edgeColls.push_back(it); + _edgeColls.emplace_back(it); _graphJson.add(arangodb::basics::Json(it)); } } diff --git a/arangod/Indexes/PathBasedIndex.cpp b/arangod/Indexes/PathBasedIndex.cpp index 79dd4d5bfb..c9daaa19e7 100644 --- a/arangod/Indexes/PathBasedIndex.cpp +++ b/arangod/Indexes/PathBasedIndex.cpp @@ -353,14 +353,13 @@ void PathBasedIndex::fillPaths(std::vector>& paths, std::vector& interior(paths.back()); int expands = -1; int count = 0; - std::vector joinedNames; for (auto const& att : list) { - interior.push_back(att.name); + interior.emplace_back(att.name); if (att.shouldExpand) { expands = count; } ++count; } - expanding.push_back(expands); + expanding.emplace_back(expands); } } diff --git a/arangod/VocBase/document-collection.cpp b/arangod/VocBase/document-collection.cpp index 9b7d508a1e..e780a1bf13 100644 --- a/arangod/VocBase/document-collection.cpp +++ b/arangod/VocBase/document-collection.cpp @@ -1305,7 +1305,7 @@ static bool OpenIterator(TRI_df_marker_t const* marker, void* data, if (marker->_type == TRI_DOC_MARKER_KEY_EDGE || marker->_type == TRI_DOC_MARKER_KEY_DOCUMENT) { res = OpenIteratorHandleDocumentMarker(marker, datafile, - (open_iterator_state_t*)data); + static_cast(data)); if (datafile->_dataMin == 0) { datafile->_dataMin = tick; @@ -1316,12 +1316,12 @@ static bool OpenIterator(TRI_df_marker_t const* marker, void* data, } } else if (marker->_type == TRI_DOC_MARKER_KEY_DELETION) { res = OpenIteratorHandleDeletionMarker(marker, datafile, - (open_iterator_state_t*)data); + static_cast(data)); } else { if (marker->_type == TRI_DF_MARKER_HEADER) { // ensure there is a datafile info entry for each datafile of the // collection - FindDatafileStats((open_iterator_state_t*)data, datafile->_fid); + FindDatafileStats(static_cast(data), datafile->_fid); } LOG(TRACE) << "skipping marker type " << marker->_type; @@ -4835,7 +4835,7 @@ int TRI_document_collection_t::updateDocument(arangodb::Transaction* trx, if (res == TRI_ERROR_NO_ERROR) { // write new header into result - *mptr = *((TRI_doc_mptr_t*)newHeader); + *mptr = *newHeader; } return res; diff --git a/arangod/VocBase/replication-applier.cpp b/arangod/VocBase/replication-applier.cpp index 054dfb66fe..af7fe0d54f 100644 --- a/arangod/VocBase/replication-applier.cpp +++ b/arangod/VocBase/replication-applier.cpp @@ -529,28 +529,31 @@ TRI_replication_applier_t* TRI_CreateReplicationApplier( //////////////////////////////////////////////////////////////////////////////// TRI_replication_applier_configuration_t:: - TRI_replication_applier_configuration_t() { - _requestTimeout = 600.0; - _connectTimeout = 10.0; - _ignoreErrors = 0; - _maxConnectRetries = 100; - _chunkSize = 0; - _sslProtocol = 0; - _autoStart = false; - _adaptivePolling = true; - _autoResync = false; - _includeSystem = true; - _requireFromPresent = false; - _verbose = false; - _incremental = false; - _restrictType = ""; - _restrictCollections.clear(); - _connectionRetryWaitTime = 15 * 1000 * 1000; - _initialSyncMaxWaitTime = 300 * 1000 * 1000; - _idleMinWaitTime = 1000 * 1000; - _idleMaxWaitTime = 5 * 500 * 1000; - _autoResyncRetries = 2; -} + TRI_replication_applier_configuration_t() + : _endpoint(), + _database(), + _username(), + _password(), + _requestTimeout(600.0), + _connectTimeout(10.0), + _ignoreErrors(0), + _maxConnectRetries(100), + _chunkSize(0), + _connectionRetryWaitTime(15 * 1000 * 1000), + _idleMinWaitTime(1000 * 1000), + _idleMaxWaitTime(5 * 500 * 1000), + _initialSyncMaxWaitTime(300 * 1000 * 1000), + _autoResyncRetries(2), + _sslProtocol(0), + _autoStart(false), + _adaptivePolling(true), + _autoResync(false), + _includeSystem(true), + _requireFromPresent(false), + _incremental(false), + _verbose(false), + _restrictType(), + _restrictCollections() {} //////////////////////////////////////////////////////////////////////////////// /// @brief reset the configuration to defaults @@ -559,10 +562,6 @@ TRI_replication_applier_configuration_t:: void TRI_replication_applier_configuration_t::reset() { TRI_replication_applier_configuration_t empty; update(&empty); - _endpoint.clear(); - _database.clear(); - _username.clear(); - _password.clear(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Wal/CollectorThread.cpp b/arangod/Wal/CollectorThread.cpp index 219f10edad..46d3930ee6 100644 --- a/arangod/Wal/CollectorThread.cpp +++ b/arangod/Wal/CollectorThread.cpp @@ -29,6 +29,7 @@ #include "Basics/Logger.h" #include "Basics/memory-map.h" #include "Basics/MutexLocker.h" +#include "Basics/VelocyPackHelper.h" #include "Indexes/PrimaryIndex.h" #include "Utils/CollectionGuard.h" #include "Utils/DatabaseGuard.h" @@ -635,7 +636,7 @@ void CollectorThread::processCollectionMarker( dfi.numberUncollected--; VPackSlice slice(reinterpret_cast(walMarker) + VPackOffset(TRI_WAL_MARKER_VPACK_DOCUMENT)); - TRI_voc_rid_t revisionId = std::stoull(slice.get(TRI_VOC_ATTRIBUTE_REV).copyString()); + TRI_voc_rid_t revisionId = arangodb::basics::VelocyPackHelper::stringUInt64(slice.get(TRI_VOC_ATTRIBUTE_REV)); auto found = document->primaryIndex()->lookupKey(&trx, slice.get(TRI_VOC_ATTRIBUTE_KEY)); @@ -665,7 +666,7 @@ void CollectorThread::processCollectionMarker( dfi.numberDeletions++; VPackSlice slice(reinterpret_cast(walMarker) + VPackOffset(TRI_WAL_MARKER_VPACK_REMOVE)); - TRI_voc_rid_t revisionId = std::stoull(slice.get(TRI_VOC_ATTRIBUTE_REV).copyString()); + TRI_voc_rid_t revisionId = arangodb::basics::VelocyPackHelper::stringUInt64(slice.get(TRI_VOC_ATTRIBUTE_REV)); auto found = document->primaryIndex()->lookupKey(&trx, slice.get(TRI_VOC_ATTRIBUTE_KEY)); diff --git a/lib/Basics/JsonHelper.cpp b/lib/Basics/JsonHelper.cpp index 2a1bf83b2b..fa140555d5 100644 --- a/lib/Basics/JsonHelper.cpp +++ b/lib/Basics/JsonHelper.cpp @@ -29,17 +29,6 @@ using namespace arangodb::basics; -//////////////////////////////////////////////////////////////////////////////// -/// @brief convert a uint64 into a JSON string -//////////////////////////////////////////////////////////////////////////////// - -TRI_json_t* JsonHelper::uint64String(TRI_memory_zone_t* zone, uint64_t value) { - char buffer[21]; - size_t len = TRI_StringUInt64InPlace(value, (char*)&buffer); - - return TRI_CreateStringCopyJson(zone, buffer, len); -} - //////////////////////////////////////////////////////////////////////////////// /// @brief convert a JSON string or number into a uint64 //////////////////////////////////////////////////////////////////////////////// @@ -70,62 +59,6 @@ uint64_t JsonHelper::stringUInt64(TRI_json_t const* json, char const* name) { return stringUInt64(element); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a JSON key/value object from a key/value of strings -//////////////////////////////////////////////////////////////////////////////// - -TRI_json_t* JsonHelper::stringObject( - TRI_memory_zone_t* zone, std::map const& values) { - TRI_json_t* json = TRI_CreateObjectJson(zone, values.size()); - - if (json == nullptr) { - return nullptr; - } - - std::map::const_iterator it; - for (it = values.begin(); it != values.end(); ++it) { - std::string const key = (*it).first; - std::string const value = (*it).second; - - TRI_json_t* v = TRI_CreateStringCopyJson(zone, value.c_str(), value.size()); - if (v != nullptr) { - TRI_Insert3ObjectJson(zone, json, key.c_str(), v); - } - } - - return json; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a key/value object of strings from a JSON (sub-) object -//////////////////////////////////////////////////////////////////////////////// - -std::map JsonHelper::stringObject( - TRI_json_t const* json) { - std::map result; - - if (isObject(json)) { - size_t const n = TRI_LengthVectorJson(json); - - for (size_t i = 0; i < n; i += 2) { - auto k = static_cast( - TRI_AtVector(&json->_value._objects, i)); - auto v = static_cast( - TRI_AtVector(&json->_value._objects, i + 1)); - - if (isString(k) && isString(v)) { - std::string const key = - std::string(k->_value._string.data, k->_value._string.length - 1); - std::string const value = - std::string(v->_value._string.data, v->_value._string.length - 1); - result.emplace(std::make_pair(key, value)); - } - } - } - - return result; -} - //////////////////////////////////////////////////////////////////////////////// /// @brief creates a JSON object from an array of strings //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Basics/JsonHelper.h b/lib/Basics/JsonHelper.h index 858ad4509c..739c04a43f 100644 --- a/lib/Basics/JsonHelper.h +++ b/lib/Basics/JsonHelper.h @@ -42,11 +42,6 @@ class JsonHelper { ~JsonHelper() = delete; public: - ////////////////////////////////////////////////////////////////////////////// - /// @brief convert a uint64 into a JSON string - ////////////////////////////////////////////////////////////////////////////// - - static TRI_json_t* uint64String(TRI_memory_zone_t*, uint64_t); ////////////////////////////////////////////////////////////////////////////// /// @brief convert a uint64 into a JSON string @@ -60,19 +55,6 @@ class JsonHelper { static uint64_t stringUInt64(TRI_json_t const*, char const*); - ////////////////////////////////////////////////////////////////////////////// - /// @brief creates a JSON object from a key/value object of strings - ////////////////////////////////////////////////////////////////////////////// - - static TRI_json_t* stringObject(TRI_memory_zone_t*, - std::map const&); - - ////////////////////////////////////////////////////////////////////////////// - /// @brief creates a key/value object of strings from a JSON (sub-) object - ////////////////////////////////////////////////////////////////////////////// - - static std::map stringObject(TRI_json_t const*); - ////////////////////////////////////////////////////////////////////////////// /// @brief creates a JSON object from an array of strings ////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Basics/StringBuffer.cpp b/lib/Basics/StringBuffer.cpp index 5c87192cee..1cf65355e8 100644 --- a/lib/Basics/StringBuffer.cpp +++ b/lib/Basics/StringBuffer.cpp @@ -403,8 +403,8 @@ static int AppendJsonEncodedValue(TRI_string_buffer_t* self, char const*& ptr, //////////////////////////////////////////////////////////////////////////////// TRI_string_buffer_t* TRI_CreateStringBuffer(TRI_memory_zone_t* zone) { - TRI_string_buffer_t* self = (TRI_string_buffer_t*)TRI_Allocate( - zone, sizeof(TRI_string_buffer_t), false); + auto self = static_cast(TRI_Allocate( + zone, sizeof(TRI_string_buffer_t), false)); if (self == nullptr) { return nullptr; @@ -421,8 +421,8 @@ TRI_string_buffer_t* TRI_CreateStringBuffer(TRI_memory_zone_t* zone) { TRI_string_buffer_t* TRI_CreateSizedStringBuffer(TRI_memory_zone_t* zone, size_t size) { - TRI_string_buffer_t* self = (TRI_string_buffer_t*)TRI_Allocate( - zone, sizeof(TRI_string_buffer_t), false); + auto self = static_cast(TRI_Allocate( + zone, sizeof(TRI_string_buffer_t), false)); if (self == nullptr) { return nullptr;