Skip to content

Commit 0a75617

Browse files
committed
Fix some code style warnings
1 parent 930b98e commit 0a75617

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

benchmark/plots/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pandas as pd
22
import numpy as np
3-
from pathlib import Path
3+
from pathlib import Path
44
import json
55
import matplotlib.pyplot as plt
66

7+
78
def load_json_benchmarks(file_path: Path) -> pd.DataFrame:
89
"""Load the benchmark results from a google benchmark json file."""
910
with open(file_path, "r") as f:
@@ -12,8 +13,8 @@ def load_json_benchmarks(file_path: Path) -> pd.DataFrame:
1213
return pd.DataFrame(data["benchmarks"])
1314

1415

15-
def filter_results(df : pd.DataFrame, library: str) -> pd.DataFrame:
16-
""""Remove mean, median and stddev from the results"""
16+
def filter_results(df: pd.DataFrame, library: str) -> pd.DataFrame:
17+
"""Remove mean, median and stddev from the results."""
1718
df_means = df.name.str.contains("mean")
1819
df_medians = df.name.str.contains("median")
1920
df_stddev = df.name.str.contains("stddev")
@@ -82,4 +83,4 @@ def plot_comparison(df):
8283

8384
ax.legend(libraries, bbox_to_anchor=(1.05, 1), loc='upper left')
8485

85-
return ax
86+
return ax

include/bencode/detail/event_connector.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class event_connector
9595
{
9696
if (!stack_.empty() && stack_.top() == connector_state::expect_dict_key) [[unlikely]] {
9797
error_ = encoding_errc::invalid_dict_key;
98+
return;
9899
}
99100
stack_.push(connector_state::expect_list_value);
100101
consumer_.begin_list();
@@ -104,6 +105,7 @@ class event_connector
104105
{
105106
if (!stack_.empty() && stack_.top() == connector_state::expect_dict_key) [[unlikely]] {
106107
error_ = encoding_errc::invalid_dict_key;
108+
return;
107109
}
108110
stack_.push(connector_state::expect_dict_key);
109111
consumer_.begin_dict();
@@ -113,6 +115,7 @@ class event_connector
113115
{
114116
if (stack_.empty() || stack_.top() != connector_state::expect_list_value) [[unlikely]] {
115117
error_ = encoding_errc::unexpected_end_list;
118+
return;
116119
}
117120

118121
stack_.pop();
@@ -127,6 +130,7 @@ class event_connector
127130
{
128131
if (stack_.empty() || stack_.top() != connector_state::expect_dict_key) [[unlikely]] {
129132
error_ = encoding_errc::unexpected_end_dict;
133+
return;
130134
}
131135

132136
stack_.pop();
@@ -139,20 +143,19 @@ class event_connector
139143

140144
template <typename U, typename T = std::remove_cvref_t<U>>
141145
requires event_producer<T>
142-
inline bool handle_dict_key(U&& key)
146+
inline void handle_dict_key(U&& key)
143147
{
144148
Expects(!stack_.empty());
145149
Expects(stack_.top() == connector_state::expect_dict_key);
146150

147151
if constexpr (!serializable_to<T, bencode_type::string>) [[unlikely]] {
148152
error_ = encoding_errc::invalid_dict_key;
149-
return false;
153+
return;
150154
}
151155

152156
stack_.top() = connector_state::expect_dict_value;
153157
connect(consumer_, std::forward<U>(key));
154158
consumer_.dict_key();
155-
return true;
156159
}
157160

158161
template <typename U, typename T = std::remove_cvref_t<U>>

include/bencode/detail/parser/from_chars.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,12 @@ constexpr from_chars_result from_chars(
147147
const char* first, const char* last, bool& value, implementation_tag<0>)
148148
{
149149
std::uint8_t v = (*first - '0');
150-
bool is_digit = v <= 9;
151150

152151
if (v <= 1) [[likely]] {
153152
value = v;
154153
return {++first, parsing_errc{}};
155154
}
156-
else if (v == is_digit) {
155+
else if (v <= 9) {
157156
return {++first, parsing_errc::result_out_of_range};
158157
}
159158
else {

tests/parser/test_from_chars.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TEMPLATE_TEST_CASE("test from_chars - serial", "[integer]", std::int32_t, std::i
9292

9393
inline std::string operator""_padded(const char* s, std::size_t len)
9494
{
95-
auto str = std::string(s, strlen(s));
95+
auto str = std::string(s, len);
9696
str.resize(32, '\0');
9797
return str;
9898
}

0 commit comments

Comments
 (0)