NewViewWithData creates a new view and initializes it with data. This function should be used with caution to avoid unnecessary []byte allocations. When in doubt use NewWithView to maximize chunk reuse in production environments.
(data []byte)
| 76 | // When in doubt use NewWithView to maximize chunk reuse in production |
| 77 | // environments. |
| 78 | func NewViewWithData(data []byte) *View { |
| 79 | c := newChunk(len(data)) |
| 80 | v := viewPool.Get().(*View) |
| 81 | *v = View{chunk: c} |
| 82 | v.Write(data) |
| 83 | return v |
| 84 | } |
| 85 | |
| 86 | // Clone creates a shallow clone of v where the underlying chunk is shared. |
| 87 | // |
searching dependent graphs…