mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-16 09:21:52 +03:00
Bug fix/clang-tidy-performance (#300)
Various clang-tidy-performance fixes: * noexcept * performance-noexcept-swap * performance * performance-move-const-arg * performance-unnecessary-value-param * performance-inefficient-vector-operation * performance-no-int-to-ptr * add performance * performance-inefficient-string-concatenation * clang-analyzer-deadcode.DeadStores * performance-inefficient-vector-operation * clang-analyzer-core.NullDereference * clang-analyzer-core.UndefinedBinaryOperatorResult * clang-analyzer-core.CallAndMessage --------- Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
This commit is contained in:
@@ -146,7 +146,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
|
||||
vector<u32> used_id;
|
||||
for (const GoughSSAVar *var : used) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
used_id.emplace_back(var->slot);
|
||||
used_id.emplace_back(var->slot); //NOLINT (performance-inefficient-vector-operation)
|
||||
}
|
||||
for (const u32 &id : used_id) {
|
||||
fprintf(f, " %u", id);
|
||||
@@ -169,7 +169,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
|
||||
vector<u32> used_id;
|
||||
for (const GoughSSAVar *var : used) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
used_id.emplace_back(var->slot);
|
||||
used_id.emplace_back(var->slot); //NOLINT (performance-inefficient-vector-operation)
|
||||
}
|
||||
for (const u32 &id : used_id) {
|
||||
fprintf(f, " %u", id);
|
||||
|
||||
@@ -628,7 +628,7 @@ void fillAccelInfo(build_info &bi) {
|
||||
vector<NFAVertex> astates;
|
||||
for (const auto &m : accel_map) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
astates.emplace_back(m.first);
|
||||
astates.emplace_back(m.first); //NOLINT (performance-inefficient-vector-operation)
|
||||
}
|
||||
|
||||
NFAStateSet useful(num_states);
|
||||
@@ -1071,7 +1071,7 @@ void buildAcceptsList(const build_info &args, ReportListCache &reports_cache,
|
||||
a.reports = addReports(h[v].reports, reports, reports_cache);
|
||||
}
|
||||
a.squash = addSquashMask(args, v, squash);
|
||||
accepts.emplace_back(std::move(a));
|
||||
accepts.emplace_back(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
|
||||
if (unlikely(ACCEPT_FUNC32(tmp))) {
|
||||
DEBUG_PRINTF("Accept state %u reached\n", tmp & SHENG32_STATE_MASK);
|
||||
u64a match_offset = base_offset + (cur_buf - buf) + 1;
|
||||
u64a match_offset = base_offset + (cur_buf - buf) + 1; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
if (STOP_AT_MATCH) {
|
||||
DEBUG_PRINTF("Stopping at match @ %lli\n",
|
||||
@@ -222,7 +222,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
|
||||
if (unlikely(ACCEPT_FUNC64(tmp))) {
|
||||
DEBUG_PRINTF("Accept state %u reached\n", tmp & SHENG64_STATE_MASK);
|
||||
u64a match_offset = base_offset + (cur_buf - buf) + 1;
|
||||
u64a match_offset = base_offset + (cur_buf - buf) + 1; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
if (STOP_AT_MATCH) {
|
||||
DEBUG_PRINTF("Stopping at match @ %lli\n",
|
||||
|
||||
@@ -392,7 +392,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
|
||||
if (unlikely(INTERESTING_FUNC32(a1, a2, a3, a4))) {
|
||||
if (ACCEPT_FUNC32(a1)) {
|
||||
u64a match_offset = base_offset + b1 - buf;
|
||||
u64a match_offset = base_offset + b1 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a1 & SHENG32_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -417,7 +417,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC32(a2)) {
|
||||
u64a match_offset = base_offset + b2 - buf;
|
||||
u64a match_offset = base_offset + b2 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a2 & SHENG32_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -442,7 +442,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC32(a3)) {
|
||||
u64a match_offset = base_offset + b3 - buf;
|
||||
u64a match_offset = base_offset + b3 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a3 & SHENG32_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -467,7 +467,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC32(a4)) {
|
||||
u64a match_offset = base_offset + b4 - buf;
|
||||
u64a match_offset = base_offset + b4 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a4 & SHENG32_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -642,7 +642,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
|
||||
if (unlikely(INTERESTING_FUNC64(a1, a2, a3, a4))) {
|
||||
if (ACCEPT_FUNC64(a1)) {
|
||||
u64a match_offset = base_offset + b1 - buf;
|
||||
u64a match_offset = base_offset + b1 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a1 & SHENG64_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -667,7 +667,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC64(a2)) {
|
||||
u64a match_offset = base_offset + b2 - buf;
|
||||
u64a match_offset = base_offset + b2 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a2 & SHENG64_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -692,7 +692,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC64(a3)) {
|
||||
u64a match_offset = base_offset + b3 - buf;
|
||||
u64a match_offset = base_offset + b3 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a3 & SHENG64_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
@@ -717,7 +717,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
|
||||
}
|
||||
}
|
||||
if (ACCEPT_FUNC64(a4)) {
|
||||
u64a match_offset = base_offset + b4 - buf;
|
||||
u64a match_offset = base_offset + b4 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
DEBUG_PRINTF("Accept state %u reached\n",
|
||||
a4 & SHENG64_STATE_MASK);
|
||||
DEBUG_PRINTF("Match @ %llu\n", match_offset);
|
||||
|
||||
@@ -104,9 +104,9 @@ const u8 *scanBlock(svuint8_t shuf_mask_lo_highclear, svuint8_t shuf_mask_lo_hig
|
||||
}
|
||||
uint64_t index;
|
||||
if (forward) {
|
||||
index = first_non_zero(vector_size_int_8, result_mask);
|
||||
index = first_non_zero(vector_size_int_8, result_mask); //NOLINT (clang-analyzer-core.CallAndMessage)
|
||||
} else {
|
||||
index = last_non_zero(vector_size_int_8, result_mask);
|
||||
index = last_non_zero(vector_size_int_8, result_mask); //NOLINT (clang-analyzer-core.CallAndMessage)
|
||||
}
|
||||
|
||||
if (index < vector_size_int_8) {
|
||||
@@ -311,7 +311,7 @@ const u8 *truffleExecReal(const m128 &shuf_mask_lo_highclear, m128 shuf_mask_lo_
|
||||
SuperVector<S> chars = SuperVector<S>::Zeroes();
|
||||
const u8* end_buf;
|
||||
if (buf_end - buf < S) {
|
||||
memcpy(&chars.u, buf, buf_end - buf);
|
||||
memcpy(&chars.u, buf, buf_end - buf); //NOLINT (clang-analyzer-core.NonNullParamChecker)
|
||||
end_buf = buf;
|
||||
} else {
|
||||
chars = SuperVector<S>::loadu(buf_end - S);
|
||||
|
||||
@@ -379,7 +379,7 @@ const u8 *vermicelliDoubleExec(char c1, char c2, bool nocase, const u8 *buf,
|
||||
}
|
||||
/* check for partial match at end */
|
||||
u8 mask = nocase ? CASE_CLEAR : 0xff;
|
||||
if ((buf_end[-1] & mask) == (u8)c1) {
|
||||
if ((buf_end[-1] & mask) == (u8)c1) { //NOLINT (clang-analyzer-core.NullDereference)
|
||||
DEBUG_PRINTF("partial!!!\n");
|
||||
return buf_end - 1;
|
||||
}
|
||||
@@ -486,7 +486,7 @@ const u8 *vermicelliDoubleMasked16Exec(const m128 mask, char c1, char m1,
|
||||
}
|
||||
}
|
||||
/* check for partial match at end */
|
||||
if ((buf_end[-1] & m1) == (u8)c1) {
|
||||
if ((buf_end[-1] & m1) == (u8)c1) { //NOLINT (clang-analyzer-core.NullDereference)
|
||||
DEBUG_PRINTF("partial!!!\n");
|
||||
return buf_end - 1;
|
||||
}
|
||||
@@ -523,7 +523,7 @@ const u8 *dvermSearchAlignedMasked(m128 chars1, m128 chars2,
|
||||
m128 v2 = eq128(chars2, and128(data, mask2));
|
||||
u32 z = movemask128(and128(v1, rshiftbyte_m128(v2, 1)));
|
||||
|
||||
if ((buf[15] & m1) == c1 && (buf[16] & m2) == c2) {
|
||||
if ((buf[15] & m1) == c1 && (buf[16] & m2) == c2) { //NOLINT (clang-analyzer-core.NullDereference)
|
||||
z |= (1 << 15);
|
||||
}
|
||||
if (unlikely(z)) {
|
||||
@@ -579,7 +579,7 @@ const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
|
||||
}
|
||||
|
||||
/* check for partial match at end */
|
||||
if ((buf_end[-1] & m1) == (u8)c1) {
|
||||
if ((buf_end[-1] & m1) == (u8)c1) { //NOLINT (clang-analyzer-core.NullDereference)
|
||||
DEBUG_PRINTF("partial!!!\n");
|
||||
return buf_end - 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user