Skip to content

Commit 6772f11

Browse files
authored
string control collection (#48)
1 parent 25a83bd commit 6772f11

File tree

3 files changed

+300
-336
lines changed

3 files changed

+300
-336
lines changed

src/safe-guides/coding_practice/collections.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ Rust 标准库内置的集合类型,在安全和性能方面还是比较靠谱
5656

5757

5858

59-
## G.CLT.01 非必要情况下,不要使用 `LinkedList`,而用 `Vec``VecDeque` 代替
59+
## G.CLT.01 非必要情况下,不要使用`LinkedList`,而用`Vec``VecDeque`代替
6060

61-
### 【级别:建议】
61+
**【级别** 建议
6262

63-
建议按此规范执行。
63+
**【描述】**
64+
65+
一般情况下,有 `Vec``VecDeque` 性能更好。`LinkedList` 存在内存浪费,缓存局部性(Cache Locality)比较差,无法更好地利用CPU 缓存机制,性能很差。
66+
67+
只有在有大量的 列表 拆分 和 合并 操作时,才真正需要链表,因为链表允许你只需操作指针而非复制数据来完成这些操作。
6468

65-
### 【Lint 检测】
69+
**【Lint 检测】**
6670

6771
| lint name | Clippy 可检测 | Rustc 可检测 | Lint Group | level |
6872
| ------------------------------------------------------------ | ------------- | ------------ | ---------- | ----- |
@@ -75,11 +79,5 @@ Rust 标准库内置的集合类型,在安全和性能方面还是比较靠谱
7579
avoid-breaking-exported-api=true
7680
```
7781

78-
### 【描述】
79-
80-
一般情况下,有 `Vec``VecDeque` 性能更好。`LinkedList` 存在内存浪费,缓存局部性(Cache Locality)比较差,无法更好地利用CPU 缓存机制,性能很差。
81-
82-
只有在有大量的 列表 拆分 和 合并 操作时,才真正需要链表,因为链表允许你只需操作指针而非复制数据来完成这些操作。
83-
8482

8583

0 commit comments

Comments
 (0)