git-hulk commented on code in PR #2277:
URL: https://github.com/apache/kvrocks/pull/2277#discussion_r1582020178
##########
src/storage/rdb_ziplist.cc:
##########
@@ -152,3 +148,65 @@ Status ZipList::peekOK(size_t n) {
}
uint32_t ZipList::getEncodedLengthSize(uint32_t len) { return len <
ZipListBigLen ? 1 : 5; }
+
+uint32_t ZipList::ZipStorePrevEntryLengthLarge(unsigned char *p, unsigned int
len) {
+ uint32_t u32 = 0;
+ if (p != nullptr) {
+ p[0] = ZipListBigLen;
+ u32 = len;
+ memcpy(p + 1, &u32, sizeof(u32));
+ memrev32ifbe(p + 1);
+ }
+ return 1 + sizeof(uint32_t);
+}
+
+uint32_t ZipList::ZipStorePrevEntryLength(unsigned char *p, unsigned int len) {
+ if (p == nullptr) {
+ return (len < ZipListBigLen) ? 1 : sizeof(uint32_t) + 1;
+ } else {
+ if (len < ZipListBigLen) {
+ p[0] = len;
+ return 1;
+ } else {
+ return ZipStorePrevEntryLengthLarge(p, len);
+ }
+ }
+}
Review Comment:
```suggestion
uint32_t ZipList::ZipStorePrevEntryLength(unsigned char *p, unsigned int
len) {
if (p == nullptr) {
return (len < ZipListBigLen) ? 1 : sizeof(uint32_t) + 1;
}
if (len < ZipListBigLen) {
p[0] = len;
return 1;
}
return ZipStorePrevEntryLengthLarge(p, len);
}
```
##########
src/storage/rdb_ziplist.h:
##########
@@ -41,4 +53,4 @@ class ZipList {
Status peekOK(size_t n);
void setPreEntryLen(uint32_t len) { pre_entry_len_ = len; }
static uint32_t getEncodedLengthSize(uint32_t len);
-};
+};
Review Comment:
```suggestion
};
```
Keep the newline at the end of file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]