Skip to content

Commit 01d8b87

Browse files
committed
Deprecate Buffer#trim{Start,End}
Deprecate `Buffer#trimStart` and `Buffer#trimEnd` in favour of `Buffer#dropInPlace` and `Buffer#dropRightInPlace`, which are more consistent with the rest of the API.
1 parent f77ad4a commit 01d8b87

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

library/src/scala/collection/mutable/Buffer.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,16 @@ trait Buffer[A]
119119
* @param n the number of elements to remove from the beginning
120120
* of this buffer.
121121
*/
122-
def trimStart(n: Int): Unit = remove(0, normalized(n))
122+
@deprecated("use dropInPlace instead", since = "2.13.4")
123+
def trimStart(n: Int): Unit = dropInPlace(n)
123124

124125
/** Removes the last ''n'' elements of this buffer.
125126
*
126127
* @param n the number of elements to remove from the end
127128
* of this buffer.
128129
*/
129-
def trimEnd(n: Int): Unit = {
130-
val norm = normalized(n)
131-
remove(length - norm, norm)
132-
}
130+
@deprecated("use dropRightInPlace instead", since = "2.13.4")
131+
def trimEnd(n: Int): Unit = dropRightInPlace(n)
133132

134133
def patchInPlace(from: Int, patch: scala.collection.IterableOnce[A], replaced: Int): this.type
135134

0 commit comments

Comments
 (0)