refactor: allow replacing folly::small_vector with alternatives

This commit is contained in:
Marcus Holland-Moritz 2024-05-22 17:43:39 +02:00
parent 17aa9881ea
commit f6e5eb0291
9 changed files with 49 additions and 19 deletions

View File

@ -33,10 +33,9 @@
#include <unordered_map>
#include <vector>
#include <folly/small_vector.h>
#include <dwarfs/entry_interface.h>
#include <dwarfs/file_stat.h>
#include <dwarfs/small_vector.h>
namespace dwarfs {
@ -151,7 +150,7 @@ class file : public entry {
private:
struct data {
using hash_type = folly::small_vector<char, 16>;
using hash_type = small_vector<char, 16>;
hash_type hash;
uint32_t refcount{1};
std::optional<uint32_t> inode_num;

View File

@ -28,11 +28,10 @@
#include <tuple>
#include <vector>
#include <folly/small_vector.h>
#include <dwarfs/inode_fragments.h>
#include <dwarfs/nilsimsa.h>
#include <dwarfs/object.h>
#include <dwarfs/small_vector.h>
#include <dwarfs/sortable_span.h>
namespace dwarfs {
@ -50,7 +49,7 @@ struct inode_options;
class inode : public object {
public:
using files_vector = folly::small_vector<file*, 1>;
using files_vector = small_vector<file*, 1>;
virtual void set_files(files_vector&& fv) = 0;
virtual void populate(size_t size) = 0;

View File

@ -27,9 +27,8 @@
#include <string>
#include <unordered_map>
#include <folly/small_vector.h>
#include <dwarfs/fragment_category.h>
#include <dwarfs/small_vector.h>
#include <dwarfs/types.h>
#include <dwarfs/gen-cpp2/metadata_types.h>
@ -57,7 +56,7 @@ class single_inode_fragment {
private:
fragment_category category_;
file_off_t length_;
folly::small_vector<thrift::metadata::chunk, 1> chunks_;
small_vector<thrift::metadata::chunk, 1> chunks_;
};
class inode_fragments {
@ -105,7 +104,7 @@ class inode_fragments {
std::unordered_map<fragment_category, file_off_t> get_category_sizes() const;
private:
folly::small_vector<single_inode_fragment, 1> fragments_;
small_vector<single_inode_fragment, 1> fragments_;
};
inline std::ostream& operator<<(std::ostream& os, inode_fragments const& frag) {

View File

@ -22,9 +22,9 @@
#pragma once
#include <folly/portability/IOVec.h>
#include <folly/small_vector.h>
#include <dwarfs/block_range.h>
#include <dwarfs/small_vector.h>
namespace dwarfs {
@ -32,8 +32,8 @@ struct iovec_read_buf {
// This covers more than 95% of reads
static constexpr size_t inline_storage = 16;
folly::small_vector<struct ::iovec, inline_storage> buf;
folly::small_vector<block_range, inline_storage> ranges;
small_vector<struct ::iovec, inline_storage> buf;
small_vector<block_range, inline_storage> ranges;
};
} // namespace dwarfs

View File

@ -30,7 +30,8 @@
#include <vector>
#include <folly/container/EvictingCacheMap.h>
#include <folly/small_vector.h>
#include <dwarfs/small_vector.h>
namespace dwarfs {
@ -153,7 +154,7 @@ class basic_offset_cache {
std::span<file_offset_type const> offsets() const { return offsets_; }
private:
folly::small_vector<file_offset_type, max_inline_offsets> offsets_;
small_vector<file_offset_type, max_inline_offsets> offsets_;
chunk_index_type first_index_{0};
};

View File

@ -31,7 +31,7 @@
#include <string>
#include <unordered_set>
#include <folly/small_vector.h>
#include <dwarfs/small_vector.h>
namespace dwarfs {
@ -95,7 +95,7 @@ class performance_monitor_proxy {
performance_monitor::timer_id id_;
performance_monitor::time_type start_;
std::optional<
folly::small_vector<uint64_t, performance_monitor::kNumInlineContext>>
small_vector<uint64_t, performance_monitor::kNumInlineContext>>
context_;
};

View File

@ -0,0 +1,33 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/**
* \author Marcus Holland-Moritz (github@mhxnet.de)
* \copyright Copyright (c) Marcus Holland-Moritz
*
* This file is part of dwarfs.
*
* dwarfs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* dwarfs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <folly/small_vector.h>
// #include <boost/container/small_vector.hpp>
namespace dwarfs {
template <typename T, size_t N>
using small_vector = folly::small_vector<T, N>;
// using small_vector = boost::container::small_vector<T, N>;
} // namespace dwarfs

View File

@ -39,7 +39,6 @@
#include <folly/Demangle.h>
#include <folly/String.h>
#include <folly/small_vector.h>
#include <folly/sorted_vector_types.h>
#include <dwarfs/categorizer.h>

View File

@ -137,7 +137,7 @@ class performance_monitor_impl : public performance_monitor {
timer_id id;
time_type start;
time_type end;
folly::small_vector<uint64_t, kNumInlineContext> context;
small_vector<uint64_t, kNumInlineContext> context;
};
explicit performance_monitor_impl(