Skip to content

Commit edd1139

Browse files
committed
[ISSUE #518]🚀Optimzie get data from Bytes
1 parent 7b7dc26 commit edd1139

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

rocketmq-store/src/index/index_file.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,16 @@ impl IndexFile {
273273
+ self.hash_slot_num * HASH_SLOT_SIZE
274274
+ next_index_to_read as usize * INDEX_SIZE;
275275

276-
let key_hash_read =
277-
i32::from_be_bytes(buffer[abs_index_pos..abs_index_pos + 4].try_into().unwrap());
278-
let phy_offset_read = i64::from_be_bytes(
279-
buffer[abs_index_pos + 4..abs_index_pos + 12]
280-
.try_into()
281-
.unwrap(),
282-
);
283-
let time_diff = i32::from_be_bytes(
284-
buffer[abs_index_pos + 12..abs_index_pos + 16]
285-
.try_into()
286-
.unwrap(),
287-
);
288-
let prev_index_read = i32::from_be_bytes(
289-
buffer[abs_index_pos + 16..abs_index_pos + 20]
290-
.try_into()
291-
.unwrap(),
292-
);
276+
let key_hash_read = buffer.slice(abs_index_pos..abs_index_pos + 4).get_i32();
277+
let phy_offset_read = buffer
278+
.slice(abs_index_pos + 4..abs_index_pos + 12)
279+
.get_i64();
280+
let time_diff = buffer
281+
.slice(abs_index_pos + 12..abs_index_pos + 16)
282+
.get_i32();
283+
let prev_index_read = buffer
284+
.slice(abs_index_pos + 16..abs_index_pos + 20)
285+
.get_i32();
293286

294287
if time_diff < 0 {
295288
break;

0 commit comments

Comments
 (0)