This is an automated email from the ASF dual-hosted git repository.
yangjie01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 1649b256133f [SPARK-45742][CORE][FOLLOWUP] Remove unnecessary null
check from `ArrayImplicits.SparkArrayOps#toImmutableArraySeq`
1649b256133f is described below
commit 1649b256133f352be8120c84513f67c8a873f0a9
Author: yangjie01 <[email protected]>
AuthorDate: Fri Nov 3 16:06:03 2023 +0800
[SPARK-45742][CORE][FOLLOWUP] Remove unnecessary null check from
`ArrayImplicits.SparkArrayOps#toImmutableArraySeq`
### What changes were proposed in this pull request?
The implementation of the `mmutable.ArraySeq.unsafeWrapArray` function is
as follows:
```scala
def unsafeWrapArray[T](x: Array[T]): ArraySeq[T] = ((x: unchecked) match {
case null => null
case x: Array[AnyRef] => new ofRef[AnyRef](x)
case x: Array[Int] => new ofInt(x)
case x: Array[Double] => new ofDouble(x)
case x: Array[Long] => new ofLong(x)
case x: Array[Float] => new ofFloat(x)
case x: Array[Char] => new ofChar(x)
case x: Array[Byte] => new ofByte(x)
case x: Array[Short] => new ofShort(x)
case x: Array[Boolean] => new ofBoolean(x)
case x: Array[Unit] => new ofUnit(x)
}).asInstanceOf[ArraySeq[T]]
```
The first case of match is null, there is no need to do another manual null
check, so this PR removes it.
### Why are the changes needed?
Remove unnecessary null check from
`ArrayImplicits.SparkArrayOps#toImmutableArraySeq`
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing test cases, such as `ArrayImplicitsSuite`.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #43641 from LuciferYang/SPARK-45742-FOLLOWUP.
Lead-authored-by: yangjie01 <[email protected]>
Co-authored-by: YangJie <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
---
common/utils/src/main/scala/org/apache/spark/util/ArrayImplicits.scala | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git
a/common/utils/src/main/scala/org/apache/spark/util/ArrayImplicits.scala
b/common/utils/src/main/scala/org/apache/spark/util/ArrayImplicits.scala
index 08997a800c95..38c2a415af3d 100644
--- a/common/utils/src/main/scala/org/apache/spark/util/ArrayImplicits.scala
+++ b/common/utils/src/main/scala/org/apache/spark/util/ArrayImplicits.scala
@@ -30,7 +30,6 @@ private[spark] object ArrayImplicits {
* Wraps an Array[T] as an immutable.ArraySeq[T] without copying.
*/
def toImmutableArraySeq: immutable.ArraySeq[T] =
- if (xs eq null) null
- else immutable.ArraySeq.unsafeWrapArray(xs)
+ immutable.ArraySeq.unsafeWrapArray(xs)
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]