Skip to content

Commit

Permalink
hashlib: simplify loopback. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Jan 20, 2025
1 parent 901935f commit aa01ef3
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions kernel/hashlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ using Hasher = HasherDJB32;
#define HASH_TOP_LOOP_FST [[nodiscard]] static inline Hasher hash
#define HASH_TOP_LOOP_SND { \
Hasher h; \
h.eat(a); \
h = hash_into(a, h); \
return h; \
}

Expand Down Expand Up @@ -239,11 +239,7 @@ struct hash_cstr_ops {
h.hash32(*(a++));
return h;
}
[[nodiscard]] static inline Hasher hash(const char *a) {
Hasher h;
h = hash_cstr_ops::hash_into(a, h);
return h;
}
HASH_TOP_LOOP_FST (const char *a) HASH_TOP_LOOP_SND
};

template <> struct hash_ops<char*> : hash_cstr_ops {};
Expand All @@ -255,11 +251,7 @@ struct hash_ptr_ops {
[[nodiscard]] static inline Hasher hash_into(const void *a, Hasher h) {
return hash_ops<uintptr_t>::hash_into((uintptr_t)a, h);
}
[[nodiscard]] static inline Hasher hash(const void *a) {
Hasher h;
h = hash_ptr_ops::hash_into(a, h);
return h;
}
HASH_TOP_LOOP_FST (const void *a) HASH_TOP_LOOP_SND
};

struct hash_obj_ops {
Expand All @@ -275,11 +267,7 @@ struct hash_obj_ops {
return h;
}
template<typename T>
[[nodiscard]] static inline Hasher hash(const T *a) {
Hasher h;
h = hash_obj_ops::hash_into(a, h);
return h;
}
HASH_TOP_LOOP_FST (const T *a) HASH_TOP_LOOP_SND
};
/**
* If you find yourself using this function, think hard
Expand Down

0 comments on commit aa01ef3

Please sign in to comment.