Skip to content

Commit c8a16b0

Browse files
committed
Remove unused code
1 parent 14f9ed9 commit c8a16b0

2 files changed

Lines changed: 0 additions & 86 deletions

File tree

native/src/base/misc.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -186,27 +186,6 @@ int parse_int(string_view s) {
186186
return parse_num<int, 10>(s);
187187
}
188188

189-
uint64_t parse_uint64_hex(string_view s) {
190-
return parse_num<uint64_t, 16>(s);
191-
}
192-
193-
uint32_t binary_gcd(uint32_t u, uint32_t v) {
194-
if (u == 0) return v;
195-
if (v == 0) return u;
196-
auto shift = __builtin_ctz(u | v);
197-
u >>= __builtin_ctz(u);
198-
do {
199-
v >>= __builtin_ctz(v);
200-
if (u > v) {
201-
auto t = v;
202-
v = u;
203-
u = t;
204-
}
205-
v -= u;
206-
} while (v != 0);
207-
return u << shift;
208-
}
209-
210189
int switch_mnt_ns(int pid) {
211190
int ret = -1;
212191
int fd = syscall(__NR_pidfd_open, pid, 0);
@@ -255,10 +234,6 @@ vector<string> split(string_view s, string_view delims) {
255234
return split_impl<string>(s, delims);
256235
}
257236

258-
vector<string_view> split_view(string_view s, string_view delims) {
259-
return split_impl<string_view>(s, delims);
260-
}
261-
262237
#undef vsnprintf
263238
int vssprintf(char *dest, size_t size, const char *fmt, va_list ap) {
264239
if (size > 0) {

native/src/base/misc.hpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -71,57 +71,6 @@ static inline void default_new(T *&p) { p = new T(); }
7171
template<class T>
7272
static inline void default_new(std::unique_ptr<T> &p) { p.reset(new T()); }
7373

74-
template<typename T, typename Impl>
75-
class stateless_allocator {
76-
public:
77-
using value_type = T;
78-
T *allocate(size_t num) { return static_cast<T*>(Impl::allocate(sizeof(T) * num)); }
79-
void deallocate(T *ptr, size_t num) { Impl::deallocate(ptr, sizeof(T) * num); }
80-
stateless_allocator() = default;
81-
stateless_allocator(const stateless_allocator&) = default;
82-
stateless_allocator(stateless_allocator&&) = default;
83-
template <typename U>
84-
stateless_allocator(const stateless_allocator<U, Impl>&) {}
85-
bool operator==(const stateless_allocator&) { return true; }
86-
bool operator!=(const stateless_allocator&) { return false; }
87-
};
88-
89-
class dynamic_bitset_impl {
90-
public:
91-
using slot_type = unsigned long;
92-
constexpr static int slot_size = sizeof(slot_type) * 8;
93-
using slot_bits = std::bitset<slot_size>;
94-
95-
size_t slots() const { return slot_list.size(); }
96-
slot_type get_slot(size_t slot) const {
97-
return slot_list.size() > slot ? slot_list[slot].to_ulong() : 0ul;
98-
}
99-
void emplace_back(slot_type l) {
100-
slot_list.emplace_back(l);
101-
}
102-
protected:
103-
slot_bits::reference get(size_t pos) {
104-
size_t slot = pos / slot_size;
105-
size_t index = pos % slot_size;
106-
if (slot_list.size() <= slot) {
107-
slot_list.resize(slot + 1);
108-
}
109-
return slot_list[slot][index];
110-
}
111-
bool get(size_t pos) const {
112-
size_t slot = pos / slot_size;
113-
size_t index = pos % slot_size;
114-
return slot_list.size() > slot && slot_list[slot][index];
115-
}
116-
private:
117-
std::vector<slot_bits> slot_list;
118-
};
119-
120-
struct dynamic_bitset : public dynamic_bitset_impl {
121-
slot_bits::reference operator[] (size_t pos) { return get(pos); }
122-
bool operator[] (size_t pos) const { return get(pos); }
123-
};
124-
12574
struct StringCmp {
12675
using is_transparent = void;
12776
bool operator()(std::string_view a, std::string_view b) const { return a < b; }
@@ -198,13 +147,6 @@ struct byte_data : public byte_view {
198147
rust::Vec<size_t> patch(byte_view from, byte_view to);
199148
};
200149

201-
template<size_t N>
202-
struct byte_array : public byte_data {
203-
byte_array() : byte_data(arr, N), arr{0} {}
204-
private:
205-
uint8_t arr[N];
206-
};
207-
208150
class byte_stream;
209151

210152
struct heap_data : public byte_data {
@@ -238,7 +180,6 @@ rust::Vec<size_t> mut_u8_patch(
238180
rust::Slice<const uint8_t> from,
239181
rust::Slice<const uint8_t> to);
240182

241-
uint64_t parse_uint64_hex(std::string_view s);
242183
int parse_int(std::string_view s);
243184

244185
using thread_entry = void *(*)(void *);
@@ -270,11 +211,9 @@ int fork_dont_care();
270211
int fork_no_orphan();
271212
void init_argv0(int argc, char **argv);
272213
void set_nice_name(const char *name);
273-
uint32_t binary_gcd(uint32_t u, uint32_t v);
274214
int switch_mnt_ns(int pid);
275215
std::string &replace_all(std::string &str, std::string_view from, std::string_view to);
276216
std::vector<std::string> split(std::string_view s, std::string_view delims);
277-
std::vector<std::string_view> split_view(std::string_view, std::string_view delims);
278217

279218
// Similar to vsnprintf, but the return value is the written number of bytes
280219
__printflike(3, 0) int vssprintf(char *dest, size_t size, const char *fmt, va_list ap);

0 commit comments

Comments
 (0)