chore(lsm): some refactoring
All checks were successful
ci/woodpecker/push/docker Pipeline was successful
All checks were successful
ci/woodpecker/push/docker Pipeline was successful
This commit is contained in:
parent
e3aad2b5e4
commit
881f2defbe
9 changed files with 60 additions and 76 deletions
|
|
@ -110,7 +110,7 @@ void lsm_str_free(lsm_str *str) {
|
|||
|
||||
uint64_t lsm_str_len(const lsm_str *str) { return str->len; }
|
||||
|
||||
const char *lsm_str_ptr(lsm_str *str) {
|
||||
const char *lsm_str_ptr(const lsm_str *str) {
|
||||
if (str->len <= 8) {
|
||||
return str->data.val;
|
||||
} else {
|
||||
|
|
@ -118,7 +118,7 @@ const char *lsm_str_ptr(lsm_str *str) {
|
|||
}
|
||||
}
|
||||
|
||||
char lsm_str_char(lsm_str *str, uint64_t index) {
|
||||
char lsm_str_char(const lsm_str *str, uint64_t index) {
|
||||
if (str->len <= 8) {
|
||||
return str->data.val[index];
|
||||
} else {
|
||||
|
|
@ -126,7 +126,7 @@ char lsm_str_char(lsm_str *str, uint64_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
lsm_error lsm_str_substr(lsm_str *out, lsm_str *str, uint64_t start,
|
||||
lsm_error lsm_str_substr(lsm_str *out, const lsm_str *str, uint64_t start,
|
||||
uint64_t end) {
|
||||
// A substring that starts past the string's length will have length 0
|
||||
uint64_t len = start < str->len ? end - start : 0;
|
||||
|
|
@ -153,7 +153,7 @@ lsm_error lsm_str_substr(lsm_str *out, lsm_str *str, uint64_t start,
|
|||
return lsm_error_ok;
|
||||
}
|
||||
|
||||
uint64_t lsm_str_cmp(lsm_str *s1, uint64_t s1_offset, lsm_str *s2,
|
||||
uint64_t lsm_str_cmp(const lsm_str *s1, uint64_t s1_offset, const lsm_str *s2,
|
||||
uint64_t s2_offset) {
|
||||
uint64_t index = 0;
|
||||
uint64_t max_len = MIN(s1->len - s1_offset, s2->len - s2_offset);
|
||||
|
|
@ -207,7 +207,7 @@ lsm_error lsm_str_split(lsm_str *s, lsm_str *s2, uint64_t index) {
|
|||
return lsm_str_truncate(s, index);
|
||||
}
|
||||
|
||||
bool lsm_str_eq(lsm_str *s1, lsm_str *s2) {
|
||||
bool lsm_str_eq(const lsm_str *s1, const lsm_str *s2) {
|
||||
if (s1->len != s2->len) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue