mirror of
https://github.com/facebook/rocksdb.git
synced 2026-10-23 08:09:02 +03:00
Summary: The non-ASCII character check in check-sources.sh used git grep -P (Perl regex), which requires git compiled with PCRE support. On systems without it, the command fails with exit code 128, which is != 1 (no match), so the check always reported a violation -- effectively dead. Even in CI where git has PCRE2 support, the check was silently broken: git grep -P uses PCRE2 in UTF mode by default, which interprets [\x80-\xFF] as a Unicode codepoint range (U+0080 to U+00FF). Characters like em-dash (U+2014), arrows (U+2192), and math symbols (U+2248, etc.) fall outside that range and were not detected. Only Latin-1 Supplement characters (U+0080-U+00FF) would have been caught. Replace with LC_ALL=C git grep using bash $'[\x80-\xff]' literal byte range, which works with basic regex in the C locale, and replace all non-ASCII characters in non-excluded source files: - em-dash to -- - arrow to -> - math symbols to ASCII equivalents (~=, <=, >=) - box-drawing characters to ASCII art Also exclude .github/ from the check, as scripts there can use non-ascii without disrupting RocksDB builds on non-UTF-8 systems. Pull Request resolved: https://github.com/facebook/rocksdb/pull/14729 Test Plan: manual / CI (make check-sources passes clean) Reviewed By: hx235 Differential Revision: D104692574 Pulled By: pdillinger fbshipit-source-id: 1d884c21056dcd83558b825a04b867f1c08e3f45
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
// Wraps a value of type T and tracks whether it has been mutated since the
|
|
// last Reset(). Reset() short-circuits when the value is not dirty -- useful
|
|
// when T::Reset() is non-trivial (allocations, container clears) and the
|
|
// value is rarely populated on a hot path.
|
|
//
|
|
// Requirements on T:
|
|
// - exposes a `void Reset()` method that returns it to a clean state.
|
|
//
|
|
// Read access via operator-> / operator* always returns a const view, so
|
|
// reads are free of dirty bookkeeping regardless of whether the wrapper
|
|
// itself is const. Mutation must go through mut(), which marks dirty and
|
|
// returns a mutable pointer.
|
|
//
|
|
// Thread safety: not thread safe. The owning object is responsible for
|
|
// synchronization.
|
|
template <typename T>
|
|
class DirtyTracked {
|
|
public:
|
|
// Forwards constructor arguments to T.
|
|
template <typename... Args>
|
|
explicit DirtyTracked(Args&&... args) : value_{std::forward<Args>(args)...} {}
|
|
|
|
// Read-only access.
|
|
const T* operator->() const { return &value_; }
|
|
const T& operator*() const { return value_; }
|
|
|
|
// Explicit mutating access -- marks dirty, returns a mutable pointer.
|
|
T* mut() {
|
|
dirty_ = true;
|
|
return &value_;
|
|
}
|
|
|
|
void Reset() {
|
|
if (dirty_) {
|
|
value_.Reset();
|
|
dirty_ = false;
|
|
}
|
|
}
|
|
|
|
private:
|
|
T value_;
|
|
bool dirty_ = false;
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|