Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmetics #76

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* Added `mbo::testing::WhenTransformedBy` which allows to compare containers after transforming them.
* Added custom Bazel flag `--//mbo/config:require_throws` which controls whether `MBO_CONFIG_REQUIRE` throw exceptions or use crash logging (the default `False` or `0`). This mostly affects containers.
* Added custom Bazel flag `--//mbo/config:limited_ordered_max_unroll_capacity`. This was undocumented as `--//mbo/container:limited_ordered_max_unroll_capacity` until now. It controls the maximum unroll size for LimitedOrdered/Map/Set.
* Added custom Bazel flag `--//mbo/config:limited_ordered_max_unroll_capacity`. This was undocumented as `--//mbo/container:limited_ordered_max_unroll_capacity` until now (though listed in the changelog). It controls the maximum unroll size for LimitedOrdered/Map/Set.

# 0.2.33

Expand Down
2 changes: 1 addition & 1 deletion mbo/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag")
load(":internal/config.bzl", "config_gen")

# Create custom bazel flag `--//mbo/container:limited_ordered_max_unroll_capacity`.
# Create custom bazel flag `--//mbo/config:limited_ordered_max_unroll_capacity`.
int_flag(
name = "limited_ordered_max_unroll_capacity",
build_setting_default = 16,
Expand Down
22 changes: 13 additions & 9 deletions mbo/config/internal/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,36 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef MBO_CONTAINER_INTERNAL_LIMITED_ORDERED_CONFIG_H_
#define MBO_CONTAINER_INTERNAL_LIMITED_ORDERED_CONFIG_H_
#ifndef MBO_CONFIG_CONFIG_H_
#define MBO_CONFIG_CONFIG_H_

#include <cstddef>

namespace mbo::config {

// The maximum unroll capacity for `LimitedOrdered` based containers: `LimitedSet` and `LimitedMap`.
// The maximum unroll capacity for `LimitedOrdered` based containers: `LimitedMap` and `LimitedSet`.
// Beyond unrolling 32 comparison steps, unrolling has deminishing returns for any architecture.
// The acceptable range is [4..32].
//
// For an Apple M2-Max and an AMD Epyc 7000 CPU, 24 turned out to be a good compromise in micro benchmarks.
// For Apple M2-Max and AMD Epyc 7000 CPU, 24 appeared to be a good compromise in micro benchmarks.
//
// For complex code inlining + unrolling might become problematic for larger values.
//
// The exact value is controlled by the custom bazel flag `--//mbo/container:limited_ordered_max_unroll_capacity`.
// This is controlled by the custom Bazel flag `--//mbo/config:limited_ordered_max_unroll_capacity`.
// When the library is built as a dependency (e.g. as `com_helly25_mbo`), then the flag becomes
// `--@com_helly_25//mbo/container:limited_ordered_max_unroll_capacity`.
// `--@com_helly_25//mbo/config:limited_ordered_max_unroll_capacity`.
static constexpr std::size_t kUnrollMaxCapacityDefault = 16;

// Config macro `MBO_CONFIG_REQUIRE_THROWS` controls whether container requirement violations
// result in throwing a `std::runtime_error` or a `ABSL_LOG_IF` (the latter (0) being the default).
// Configuration that controls whether container requirement violations result in throwing a
// `std::runtime_error` or crashing using `ABSL_LOG_IF` (the latter being the default).
//
// When exceptions are used then the affected functions cannot be declared `noexcept`.
//
// This is controlled by custom Bazel `--//mbo/config:require_throws`.
// When the library is built as a dependency (e.g. as `com_helly25_mbo`), then the flag becomes
// `--@com_helly_25//mbo/config:require_throws` (defaults to `False` / `0`).
static constexpr bool kRequireThrows = false;

} // namespace mbo::config

#endif // MBO_CONTAINER_INTERNAL_LIMITED_ORDERED_CONFIG_H_
#endif // MBO_CONFIG_CONFIG_H_
6 changes: 3 additions & 3 deletions mbo/config/require.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef MBO_CONTAINER_INTERNAL_REQUIRE_H_
#define MBO_CONTAINER_INTERNAL_REQUIRE_H_
#ifndef MBO_CONFIG_REQUIRE_H_
#define MBO_CONFIG_REQUIRE_H_

#include <stdexcept> // IWYU pragma: keep

Expand Down Expand Up @@ -47,4 +47,4 @@

// NOLINTEND(cppcoreguidelines-macro-usage)

#endif // MBO_CONTAINER_INTERNAL_REQUIRE_H_
#endif // MBO_CONFIG_REQUIRE_H_
Loading