[stdlib] Reduce usage of extension functions
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
internal fun <T> arrayConcat(vararg args: T): T {
|
||||
val len = args.size
|
||||
val typed = js("Array(len)").unsafeCast<Array<T>>()
|
||||
for (i in 0 until len) {
|
||||
for (i in 0 .. (len - 1)) {
|
||||
val arr = args[i]
|
||||
if (arr !is Array<*>) {
|
||||
typed[i] = js("[]").slice.call(arr)
|
||||
@@ -25,7 +25,7 @@ internal fun <T> arrayConcat(vararg args: T): T {
|
||||
@PublishedApi
|
||||
internal fun <T> primitiveArrayConcat(vararg args: T): T {
|
||||
var size = 0
|
||||
for (i in 0 until args.size) {
|
||||
for (i in 0 .. (args.size - 1)) {
|
||||
size += args[i].unsafeCast<Array<Any?>>().size
|
||||
}
|
||||
val a = args[0]
|
||||
@@ -35,9 +35,9 @@ internal fun <T> primitiveArrayConcat(vararg args: T): T {
|
||||
}
|
||||
|
||||
size = 0
|
||||
for (i in 0 until args.size) {
|
||||
for (i in 0 .. (args.size - 1)) {
|
||||
val arr = args[i].unsafeCast<Array<Any?>>()
|
||||
for (j in 0 until arr.size) {
|
||||
for (j in 0 .. (arr.size - 1)) {
|
||||
result[size++] = arr[j]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,355 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.ranges
|
||||
|
||||
// FIXME: Use stdlib _Ranges.kt instead
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Byte): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Char.downTo(to: Char): CharProgression {
|
||||
return CharProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Int): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Short): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value should be less than or equal to `this` value.
|
||||
* If the [to] value is greater than `this` value the returned progression is empty.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Byte): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Byte): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to `'\u0000'` the returned range is empty.
|
||||
*/
|
||||
public infix fun Char.until(to: Char): CharRange {
|
||||
if (to <= '\u0000') return CharRange.EMPTY
|
||||
return this .. (to - 1).toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Int): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Short): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Short): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `this` value the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
Reference in New Issue
Block a user