From 97af93b2a8ebc89364852e3f63e9fd8cfedaeedf Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Mon, 9 Jun 2025 13:43:45 +0300 Subject: =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D1=91=D0=BB=20dotfiles?= =?UTF-8?q?=20=D0=BD=D0=B0=20stow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zsh/theme/gitstatus/src/algorithm.h | 37 --- zsh/theme/gitstatus/src/arena.cc | 118 ------- zsh/theme/gitstatus/src/arena.h | 273 ---------------- zsh/theme/gitstatus/src/bits.h | 29 -- zsh/theme/gitstatus/src/check.h | 61 ---- zsh/theme/gitstatus/src/check_dir_mtime.cc | 157 --------- zsh/theme/gitstatus/src/check_dir_mtime.h | 31 -- zsh/theme/gitstatus/src/dir.cc | 237 -------------- zsh/theme/gitstatus/src/dir.h | 50 --- zsh/theme/gitstatus/src/git.cc | 250 -------------- zsh/theme/gitstatus/src/git.h | 115 ------- zsh/theme/gitstatus/src/gitstatus.cc | 219 ------------- zsh/theme/gitstatus/src/index.cc | 456 -------------------------- zsh/theme/gitstatus/src/index.h | 84 ----- zsh/theme/gitstatus/src/logging.cc | 139 -------- zsh/theme/gitstatus/src/logging.h | 124 ------- zsh/theme/gitstatus/src/options.cc | 362 --------------------- zsh/theme/gitstatus/src/options.h | 78 ----- zsh/theme/gitstatus/src/print.h | 101 ------ zsh/theme/gitstatus/src/repo.cc | 503 ----------------------------- zsh/theme/gitstatus/src/repo.h | 126 -------- zsh/theme/gitstatus/src/repo_cache.cc | 167 ---------- zsh/theme/gitstatus/src/repo_cache.h | 60 ---- zsh/theme/gitstatus/src/request.cc | 130 -------- zsh/theme/gitstatus/src/request.h | 50 --- zsh/theme/gitstatus/src/response.cc | 73 ----- zsh/theme/gitstatus/src/response.h | 50 --- zsh/theme/gitstatus/src/scope_guard.h | 56 ---- zsh/theme/gitstatus/src/serialization.h | 28 -- zsh/theme/gitstatus/src/stat.h | 23 -- zsh/theme/gitstatus/src/string_cmp.h | 151 --------- zsh/theme/gitstatus/src/string_view.h | 77 ----- zsh/theme/gitstatus/src/strings.cc | 71 ---- zsh/theme/gitstatus/src/strings.h | 37 --- zsh/theme/gitstatus/src/tag_db.cc | 332 ------------------- zsh/theme/gitstatus/src/tag_db.h | 79 ----- zsh/theme/gitstatus/src/thread_pool.cc | 87 ----- zsh/theme/gitstatus/src/thread_pool.h | 74 ----- zsh/theme/gitstatus/src/time.h | 14 - zsh/theme/gitstatus/src/timer.cc | 72 ----- zsh/theme/gitstatus/src/timer.h | 36 --- zsh/theme/gitstatus/src/tribool.h | 27 -- 42 files changed, 5244 deletions(-) delete mode 100644 zsh/theme/gitstatus/src/algorithm.h delete mode 100644 zsh/theme/gitstatus/src/arena.cc delete mode 100644 zsh/theme/gitstatus/src/arena.h delete mode 100644 zsh/theme/gitstatus/src/bits.h delete mode 100644 zsh/theme/gitstatus/src/check.h delete mode 100644 zsh/theme/gitstatus/src/check_dir_mtime.cc delete mode 100644 zsh/theme/gitstatus/src/check_dir_mtime.h delete mode 100644 zsh/theme/gitstatus/src/dir.cc delete mode 100644 zsh/theme/gitstatus/src/dir.h delete mode 100644 zsh/theme/gitstatus/src/git.cc delete mode 100644 zsh/theme/gitstatus/src/git.h delete mode 100644 zsh/theme/gitstatus/src/gitstatus.cc delete mode 100644 zsh/theme/gitstatus/src/index.cc delete mode 100644 zsh/theme/gitstatus/src/index.h delete mode 100644 zsh/theme/gitstatus/src/logging.cc delete mode 100644 zsh/theme/gitstatus/src/logging.h delete mode 100644 zsh/theme/gitstatus/src/options.cc delete mode 100644 zsh/theme/gitstatus/src/options.h delete mode 100644 zsh/theme/gitstatus/src/print.h delete mode 100644 zsh/theme/gitstatus/src/repo.cc delete mode 100644 zsh/theme/gitstatus/src/repo.h delete mode 100644 zsh/theme/gitstatus/src/repo_cache.cc delete mode 100644 zsh/theme/gitstatus/src/repo_cache.h delete mode 100644 zsh/theme/gitstatus/src/request.cc delete mode 100644 zsh/theme/gitstatus/src/request.h delete mode 100644 zsh/theme/gitstatus/src/response.cc delete mode 100644 zsh/theme/gitstatus/src/response.h delete mode 100644 zsh/theme/gitstatus/src/scope_guard.h delete mode 100644 zsh/theme/gitstatus/src/serialization.h delete mode 100644 zsh/theme/gitstatus/src/stat.h delete mode 100644 zsh/theme/gitstatus/src/string_cmp.h delete mode 100644 zsh/theme/gitstatus/src/string_view.h delete mode 100644 zsh/theme/gitstatus/src/strings.cc delete mode 100644 zsh/theme/gitstatus/src/strings.h delete mode 100644 zsh/theme/gitstatus/src/tag_db.cc delete mode 100644 zsh/theme/gitstatus/src/tag_db.h delete mode 100644 zsh/theme/gitstatus/src/thread_pool.cc delete mode 100644 zsh/theme/gitstatus/src/thread_pool.h delete mode 100644 zsh/theme/gitstatus/src/time.h delete mode 100644 zsh/theme/gitstatus/src/timer.cc delete mode 100644 zsh/theme/gitstatus/src/timer.h delete mode 100644 zsh/theme/gitstatus/src/tribool.h (limited to 'zsh/theme/gitstatus/src') diff --git a/zsh/theme/gitstatus/src/algorithm.h b/zsh/theme/gitstatus/src/algorithm.h deleted file mode 100644 index b87b13f..0000000 --- a/zsh/theme/gitstatus/src/algorithm.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus 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. -// -// GitStatus 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 GitStatus. If not, see . - -#ifndef ROMKATV_GITSTATUS_ALGORITHM_H_ -#define ROMKATV_GITSTATUS_ALGORITHM_H_ - -#include - -namespace gitstatus { - -// Requires: Iter is a BidirectionalIterator. -// -// Returns iterator pointing to the last value in [begin, end) that compares equal to the value, or -// begin if none compare equal. -template -Iter FindLast(Iter begin, Iter end, const T& val) { - while (begin != end && !(*--end == val)) {} - return end; -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_ALGORITHM_H_ diff --git a/zsh/theme/gitstatus/src/arena.cc b/zsh/theme/gitstatus/src/arena.cc deleted file mode 100644 index 4c13763..0000000 --- a/zsh/theme/gitstatus/src/arena.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus 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. -// -// GitStatus 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 GitStatus. If not, see . - -#include "arena.h" - -#include -#include - -#include "bits.h" -#include "check.h" - -namespace gitstatus { - -namespace { - -size_t Clamp(size_t min, size_t val, size_t max) { return std::min(max, std::max(min, val)); } - -static const uintptr_t kSingularity = reinterpret_cast(&kSingularity); - -} // namespace - -// Triple singularity. We are all fucked. -Arena::Block Arena::g_empty_block = {kSingularity, kSingularity, kSingularity}; - -Arena::Arena(Arena::Options opt) : opt_(std::move(opt)), top_(&g_empty_block) { - CHECK(opt_.min_block_size <= opt_.max_block_size); -} - -Arena::Arena(Arena&& other) : Arena() { *this = std::move(other); } - -Arena::~Arena() { - // See comments in Makefile for the reason sized deallocation is not used. - for (const Block& b : blocks_) ::operator delete(reinterpret_cast(b.start)); -} - -Arena& Arena::operator=(Arena&& other) { - if (this != &other) { - // In case std::vector ever gets small object optimization. - size_t idx = other.reusable_ ? other.top_ - other.blocks_.data() : 0; - opt_ = other.opt_; - blocks_ = std::move(other.blocks_); - reusable_ = other.reusable_; - top_ = reusable_ ? blocks_.data() + idx : &g_empty_block; - other.blocks_.clear(); - other.reusable_ = 0; - other.top_ = &g_empty_block; - } - return *this; -} - -void Arena::Reuse(size_t num_blocks) { - reusable_ = std::min(reusable_, num_blocks); - for (size_t i = reusable_; i != blocks_.size(); ++i) { - const Block& b = blocks_[i]; - // See comments in Makefile for the reason sized deallocation is not used. - ::operator delete(reinterpret_cast(b.start)); - } - blocks_.resize(reusable_); - if (reusable_) { - top_ = blocks_.data(); - top_->tip = top_->start; - } else { - top_ = &g_empty_block; - } -} - -void Arena::AddBlock(size_t size, size_t alignment) { - if (alignment > alignof(std::max_align_t)) { - size += alignment - 1; - } else { - size = std::max(size, alignment); - } - if (size <= top_->size() && top_ < blocks_.data() + reusable_ - 1) { - assert(blocks_.front().size() == top_->size()); - ++top_; - top_->tip = top_->start; - return; - } - if (size <= opt_.max_alloc_threshold) { - size = - std::max(size, Clamp(opt_.min_block_size, NextPow2(top_->size() + 1), opt_.max_block_size)); - } - - auto p = reinterpret_cast(::operator new(size)); - blocks_.push_back(Block{p, p, p + size}); - if (reusable_) { - if (size < blocks_.front().size()) { - top_ = &blocks_.back(); - return; - } - if (size > blocks_.front().size()) reusable_ = 0; - } - std::swap(blocks_.back(), blocks_[reusable_]); - top_ = &blocks_[reusable_++]; -} - -void* Arena::AllocateSlow(size_t size, size_t alignment) { - assert(alignment && !(alignment & (alignment - 1))); - AddBlock(size, alignment); - assert(Align(top_->tip, alignment) + size <= top_->end); - return Allocate(size, alignment); -} - -} // namespace gitstatus diff --git a/zsh/theme/gitstatus/src/arena.h b/zsh/theme/gitstatus/src/arena.h deleted file mode 100644 index 569833c..0000000 --- a/zsh/theme/gitstatus/src/arena.h +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus 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. -// -// GitStatus 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 GitStatus. If not, see . - -#ifndef ROMKATV_GITSTATUS_ARENA_H_ -#define ROMKATV_GITSTATUS_ARENA_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "string_view.h" - -namespace gitstatus { - -// Thread-compatible. Very fast and very flexible w.r.t. allocation size and alignment. -// -// Natural API extensions: -// -// // Donates a block to the arena. When the time comes, it'll be freed with -// // free(p, size, userdata). -// void Donate(void* p, size_t size, void* userdata, void(*free)(void*, size_t, void*)); -class Arena { - public: - struct Options { - // The first call to Allocate() will allocate a block of this size. There is one exception when - // the first requested allocation size is larger than this limit. Subsequent blocks will be - // twice as large as the last until they saturate at max_block_size. - size_t min_block_size = 64; - - // Allocate blocks at most this large. There is one exception when the requested allocation - // size is larger than this limit. - size_t max_block_size = 8 << 10; - - // When the size of the first allocation in a block is larger than this threshold, the block - // size will be equal to the allocation size. This is meant to reduce memory waste when making - // many allocations with sizes slightly over max_block_size / 2. With max_alloc_threshold equal - // to max_block_size / N, the upper bound on wasted memory when making many equally-sized - // allocations is 100.0 / (N + 1) percent. When making allocations of different sizes, the upper - // bound on wasted memory is 50%. - size_t max_alloc_threshold = 1 << 10; - - // Natural extensions: - // - // void* userdata; - // void (*alloc)(size_t size, size_t alignment, void* userdata); - // void (*free)(void* p, size_t size, void* userdata); - }; - - // Requires: opt.min_block_size <= opt.max_block_size. - // - // Doesn't allocate any memory. - Arena(Options opt); - Arena() : Arena(Options()) {} - Arena(Arena&&); - ~Arena(); - - Arena& operator=(Arena&& other); - - // Requires: alignment is a power of 2. - // - // Result is never null and always aligned. If size is zero, the result may be equal to the last. - // Alignment above alignof(std::max_align_t) is supported. There is no requirement for alignment - // to be less than size or to divide it. - inline void* Allocate(size_t size, size_t alignment) { - assert(alignment && !(alignment & (alignment - 1))); - uintptr_t p = Align(top_->tip, alignment); - uintptr_t e = p + size; - if (e <= top_->end) { - top_->tip = e; - return reinterpret_cast(p); - } - return AllocateSlow(size, alignment); - } - - template - inline T* Allocate(size_t n) { - static_assert(!std::is_reference(), ""); - return static_cast(Allocate(n * sizeof(T), alignof(T))); - } - - template - inline T* Allocate() { - return Allocate(1); - } - - inline char* MemDup(const char* p, size_t len) { - char* res = Allocate(len); - std::memcpy(res, p, len); - return res; - } - - // Copies the null-terminated string (including the trailing null character) to the arena and - // returns a pointer to the copy. - inline char* StrDup(const char* s) { - size_t len = std::strlen(s); - return MemDup(s, len + 1); - } - - // Guarantees: !StrDup(p, len)[len]. - inline char* StrDup(const char* p, size_t len) { - char* res = Allocate(len + 1); - std::memcpy(res, p, len); - res[len] = 0; - return res; - } - - // Guarantees: !StrDup(s)[s.len]. - inline char* StrDup(StringView s) { - return StrDup(s.ptr, s.len); - } - - template - inline char* StrCat(const Ts&... ts) { - return [&](std::initializer_list ss) { - size_t len = 0; - for (StringView s : ss) len += s.len; - char* p = Allocate(len + 1); - for (StringView s : ss) { - std::memcpy(p, s.ptr, s.len); - p += s.len; - } - *p = 0; - return p - len; - }({ts...}); - } - - // Copies/moves `val` to the arena and returns a pointer to it. - template - inline std::remove_const_t>* Dup(T&& val) { - return DirectInit>>(std::forward(val)); - } - - // The same as `new T{args...}` but on the arena. - template - inline T* DirectInit(Args&&... args) { - T* res = Allocate(); - ::new (const_cast(static_cast(res))) T(std::forward(args)...); - return res; - } - - // The same as `new T(args...)` but on the arena. - template - inline T* BraceInit(Args&&... args) { - T* res = Allocate(); - ::new (const_cast(static_cast(res))) T{std::forward(args)...}; - return res; - } - - // Tip() and TipSize() allow you to allocate the remainder of the current block. They can be - // useful if you are flexible w.r.t. the allocation size. - // - // Invariant: - // - // const void* tip = Tip(); - // void* p = Allocate(TipSize(), 1); // grab the remainder of the current block - // assert(p == tip); - const void* Tip() const { return reinterpret_cast(top_->tip); } - size_t TipSize() const { return top_->end - top_->tip; } - - // Invalidates all allocations (without running destructors of allocated objects) and frees all - // blocks except at most the specified number of blocks. The retained blocks will be used to - // fulfil future allocation requests. - void Reuse(size_t num_blocks = std::numeric_limits::max()); - - private: - struct Block { - size_t size() const { return end - start; } - uintptr_t start; - uintptr_t tip; - uintptr_t end; - }; - - inline static size_t Align(size_t n, size_t m) { return (n + m - 1) & ~(m - 1); }; - - void AddBlock(size_t size, size_t alignment); - bool ReuseBlock(size_t size, size_t alignment); - - __attribute__((noinline)) void* AllocateSlow(size_t size, size_t alignment); - - Options opt_; - std::vector blocks_; - // Invariant: !blocks_.empty() <= reusable_ && reusable_ <= blocks_.size(). - size_t reusable_ = 0; - // Invariant: (top_ == &g_empty_block) == blocks_.empty(). - // Invariant: blocks_.empty() || top_ == &blocks_.back() || top_ < blocks_.data() + reusable_. - Block* top_; - - static Block g_empty_block; -}; - -// Copies of ArenaAllocator use the same thread-compatible Arena without synchronization. -template -class ArenaAllocator { - public: - using value_type = T; - using pointer = T*; - using const_pointer = const T*; - using reference = T&; - using const_reference = const T&; - using size_type = size_t; - using difference_type = ptrdiff_t; - using propagate_on_container_move_assignment = std::true_type; - template - struct rebind { - using other = ArenaAllocator; - }; - using is_always_equal = std::false_type; - - ArenaAllocator(Arena* arena = nullptr) : arena_(*arena) {} - - Arena& arena() const { return arena_; } - - pointer address(reference x) const { return &x; } - const_pointer address(const_reference x) const { return &x; } - pointer allocate(size_type n, const void* hint = nullptr) { return arena_.Allocate(n); } - void deallocate(T* p, std::size_t n) {} - size_type max_size() const { return std::numeric_limits::max() / sizeof(value_type); } - - template - void construct(U* p, Args&&... args) { - ::new (const_cast(static_cast(p))) U(std::forward(args)...); - } - - template - void destroy(U* p) { - p->~U(); - } - - bool operator==(const ArenaAllocator& other) const { return &arena_ == &other.arena_; } - bool operator!=(const ArenaAllocator& other) const { return &arena_ != &other.arena_; } - - private: - Arena& arena_; -}; - -template -struct LazyWithArena; - -template