achingbrain / achingbrain/uint8arraylist

Optimize for common usage with libp2p

Đang mở
#59 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
11
Fork
9
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

In many cases for the libp2p packages this lib is only used for the cases when N = 1, and the flow is usually "append" -> "sublist" -> "consume". Usually, also, the array only contains 1 element.

So

1). Append
Initialize the empty array in the constructur, and append 1 element to it

2). Sublist
Aquire a sublist which is in many cases just a shallow copy of this array

3). Consume
Make the array empty again

---
If this lib instead of utilize an ```linked list``` instead, we could in theory get overall better performance.

1). Append
On appending the first element, the head is set to the first element

2).
A shallow copy

3).
set the head and tail to be undefined

We could do even better, if we combine 2 and 3 into one method called "splice", we can cut the linked list at an appropriate place, which means that we will do much less operations.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.