@@ -86,12 +86,12 @@ impl<A> Array<A, Ix2> {
86
86
/// Appending automatically changes memory layout of the array so that it is appended to
87
87
/// along the "growing axis".
88
88
///
89
- /// Ensure appending is efficient by for example starting appending an empty array and
89
+ /// Ensure appending is efficient by, for example, appending to an empty array and then
90
90
/// always appending along the same axis. For rows, ndarray's default layout is efficient for
91
91
/// appending.
92
92
///
93
93
/// Notice that an empty array (where it has an axis of length zero) is the simplest starting
94
- /// point. The amortized average complexity of the append is O(m) where *m* is the length of
94
+ /// point. When repeatedly appending to a single axis, the amortized average complexity of each append is O(m), where *m* is the length of
95
95
/// the row.
96
96
///
97
97
/// ```rust
@@ -123,12 +123,12 @@ impl<A> Array<A, Ix2> {
123
123
/// Appending automatically changes memory layout of the array so that it is appended to
124
124
/// along the "growing axis".
125
125
///
126
- /// Ensure appending is efficient by for example starting appending an empty array and
126
+ /// Ensure appending is efficient by, for example, appending to an empty array and then
127
127
/// always appending along the same axis. For columns, column major ("F") memory layout is
128
128
/// efficient for appending.
129
129
///
130
130
/// Notice that an empty array (where it has an axis of length zero) is the simplest starting
131
- /// point. The amortized average complexity of the append is O(m) where *m* is the length of
131
+ /// point. When repeatedly appending to a single axis, the amortized average complexity of each append is O(m), where *m* is the length of
132
132
/// the row.
133
133
///
134
134
/// ```rust
@@ -222,15 +222,16 @@ impl<A, D> Array<A, D>
222
222
#[ cold]
223
223
fn drop_unreachable_elements_slow ( mut self ) -> OwnedRepr < A > {
224
224
// "deconstruct" self; the owned repr releases ownership of all elements and we
225
- // and carry on with raw view methods
225
+ // carry on with raw view methods
226
226
let self_len = self . len ( ) ;
227
227
let data_len = self . data . len ( ) ;
228
228
let data_ptr = self . data . as_nonnull_mut ( ) . as_ptr ( ) ;
229
229
230
230
let mut self_;
231
231
232
232
unsafe {
233
- // Safety: self.data releases ownership of the elements
233
+ // Safety: self.data releases ownership of the elements. Any panics below this point
234
+ // will result in leaking elements instead of double drops.
234
235
self_ = self . raw_view_mut ( ) ;
235
236
self . data . set_len ( 0 ) ;
236
237
}
@@ -430,7 +431,7 @@ impl<A, D> Array<A, D>
430
431
}
431
432
}
432
433
433
- // array must be be "full" (have no exterior holes)
434
+ // array must be be "full" (contiguous and have no exterior holes)
434
435
if self . len ( ) != self . data . len ( ) {
435
436
incompatible_layout = true ;
436
437
}
@@ -520,7 +521,7 @@ impl<A, D> Array<A, D>
520
521
tail_view. shape( ) , tail_view. strides( ) ) ;
521
522
}
522
523
523
- // Keep track of currently filled lenght of `self.data` and update it
524
+ // Keep track of currently filled length of `self.data` and update it
524
525
// on scope exit (panic or loop finish).
525
526
struct SetLenOnDrop < ' a , A : ' a > {
526
527
len : usize ,
@@ -646,4 +647,3 @@ where
646
647
}
647
648
}
648
649
}
649
-
0 commit comments