1. Список говнокодов пользователя gnusmas

    Всего: 3

  2. C++ / Говнокод #29240

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    namespace arangodb {
    class DatabaseFeature;
    
    struct IDatabaseGuard {
      virtual ~IDatabaseGuard() = default;
      [[nodiscard]] virtual TRI_vocbase_t& database() const noexcept = 0;
    };
    
    struct VocbaseReleaser {
      void operator()(TRI_vocbase_t* vocbase) const noexcept;
    };
    
    using VocbasePtr = std::unique_ptr<TRI_vocbase_t, VocbaseReleaser>;
    
    /// @brief Scope guard for a database, ensures that it is not
    ///        dropped while still using it.
    class DatabaseGuard final : public IDatabaseGuard {
     public:
      /// @brief create guard on existing db
      explicit DatabaseGuard(TRI_vocbase_t& vocbase);
    
      /// @brief create guard from existing VocbasePtr
      explicit DatabaseGuard(VocbasePtr vocbase);
    
      /// @brief create the guard, using a database id
      DatabaseGuard(DatabaseFeature& feature, TRI_voc_tick_t id);
    
      /// @brief create the guard, using a database name
      DatabaseGuard(DatabaseFeature& feature, std::string_view name);
    
      /// @brief return the database pointer
      TRI_vocbase_t& database() const noexcept final { return *_vocbase; }
      TRI_vocbase_t const* operator->() const noexcept { return _vocbase.get(); }
      TRI_vocbase_t* operator->() noexcept { return _vocbase.get(); }
    
     private:
      VocbasePtr _vocbase;
    };
    
    }  // namespace arangodb

    Виртуальное гавно!

    gnusmas, 19 Марта 2026

    Комментарии (0)
  3. C++ / Говнокод #27303

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    metrics_key::metrics_key(std::initializer_list<std::string> const& il) {
      TRI_ASSERT(il.size() > 0);
      TRI_ASSERT(il.size() < 3);
      name = *il.begin();
      if (il.size() == 2) {
        labels = *(il.begin()+1);
      }
      _hash = std::hash<std::string>{}(name + labels);
    }

    просто гавно

    gnusmas, 18 Марта 2021

    Комментарии (36)
  4. C++ / Говнокод #26054

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    template<typename T> Histogram<T>& histogram (std::string const& name) {
        std::lock_guard<std::mutex> guard(_lock);
        auto const it = _registry.find(name);
        if (it == _registry.end()) {
          LOG_TOPIC("32d85", ERR, Logger::STATISTICS) << "No histogram booked as " << name;
          TRI_ASSERT(false);
          throw std::exception();
        } 
        std::shared_ptr<Histogram<T>> h = nullptr;
        try {
          h = std::dynamic_pointer_cast<Histogram<T>>(*it->second);
          if (h == nullptr) {
            LOG_TOPIC("d2358", ERR, Logger::STATISTICS) << "Failed to retrieve histogram " << name;
          }
        } catch (std::exception const& e) {
          LOG_TOPIC("32d75", ERR, Logger::STATISTICS)
            << "Failed to retrieve histogram " << name << ": " << e.what();
        }
        if (h == nullptr) {
          TRI_ASSERT(false);
        }
    
        return *h;
      };

    gnusmas, 27 Ноября 2019

    Комментарии (1)