File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,9 @@ pub fn Bytes::from_fixedarray(arr : FixedArray[Byte], len? : Int) -> Bytes {
74
74
None => arr .length ()
75
75
Some (x ) => x
76
76
}
77
- Bytes ::makei (len , i => arr [i ])
77
+ let result = FixedArray ::make (len , Byte ::default ())
78
+ arr .blit_to (result , len ~)
79
+ result .unsafe_reinterpret_as_bytes ()
78
80
}
79
81
80
82
///|
@@ -171,15 +173,17 @@ pub fn from_iter(iter : Iter[Byte]) -> Bytes {
171
173
/// ),
172
174
/// )
173
175
/// ```
174
- /// TODO: marked as intrinsic, inline if it is constant
175
176
pub fn Bytes ::of (arr : FixedArray [Byte ]) -> Bytes {
176
- Bytes ::makei (arr .length (), i => arr [i ])
177
+ let len = arr .length ()
178
+ let result = FixedArray ::make (len , Byte ::default ())
179
+ arr .blit_to (result , len ~)
180
+ result .unsafe_reinterpret_as_bytes ()
177
181
}
178
182
179
183
///|
180
184
/// same as `Bytes::of`
181
185
pub fn of (arr : FixedArray [Byte ]) -> Bytes {
182
- Bytes ::makei (arr . length (), i => arr [ i ] )
186
+ Bytes ::of (arr )
183
187
}
184
188
185
189
///|
You can’t perform that action at this time.
0 commit comments