知识卡片
写时克隆延迟复制
Cow可保存借用数据或拥有数据:只读时沿用借用,需修改借用内容时才转为拥有副本。它把复制延迟到真正需要写入的路径,减少无修改时的成本。若输入本来已拥有,修改也不必先复制;收益取决于实际写入比例。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 写时克隆延迟复制
原书出处 · 1 处
- Chapter 1. Types More Pointer Traits · 查看原书依据
clone-on-write”: a Cow input can remain as borrowed data right up to the point where it needs to be modified, but it becomes an owned copy at the point where the data needs to be altered.
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第1章《More Pointer Traits》(spine5;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch01.html;u045-ch01-063)。
- 结论依据:原文在“clone-on-write”附近的定义、例子或代码支撑本卡核心说明:Cow可保存借用数据或拥有数据:只读时沿用借用,需修改借用内容时才转为拥有副本。边界按已读前提解释;示例未执行。
- 原始内容:clone-on-write”: a Cow input can remain as borrowed data right up to the point where it needs to be modified, but it becomes an owned copy at the point where the data needs to be altered.