Skip to content

Commit cb07b5e

Browse files
committed
glib: Fix inverted boolean conditions when deciding whether to reserve new space
Fixes #1075
1 parent 4510666 commit cb07b5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

glib/src/collections/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<T: TransparentType> Slice<T> {
688688
#[inline]
689689
pub fn extend_from_slice(&mut self, other: &[T]) {
690690
// Nothing new to reserve as there's still enough space
691-
if self.len + other.len() <= self.capacity {
691+
if self.len + other.len() > self.capacity {
692692
self.reserve(other.len());
693693
}
694694

@@ -709,7 +709,7 @@ impl<T: TransparentType> Slice<T> {
709709
assert!(index <= self.len);
710710

711711
// Nothing new to reserve as there's still enough space
712-
if self.len + 1 <= self.capacity {
712+
if self.len + 1 > self.capacity {
713713
self.reserve(1);
714714
}
715715

@@ -732,7 +732,7 @@ impl<T: TransparentType> Slice<T> {
732732
#[allow(clippy::int_plus_one)]
733733
pub fn push(&mut self, item: T) {
734734
// Nothing new to reserve as there's still enough space
735-
if self.len + 1 <= self.capacity {
735+
if self.len + 1 > self.capacity {
736736
self.reserve(1);
737737
}
738738

0 commit comments

Comments
 (0)