Skip to content

Commit 66ae3f4

Browse files
committed
Fix typos
1 parent 383486f commit 66ae3f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/_docs/internals/specialized-traits.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ but that would make it less generally usable. Another alternative is to optimize
342342
def sumElems(xs: Vector[Int]): Int =
343343
val faster: faster.Vector[Int] | Null = xs match
344344
case xs: faster.Vector[_] => xs
345-
case _ => xs
345+
case _ => null
346346
var i = 0
347347
var sum = 0
348348
while i < xs.length do
349349
sum += (if faster != null then faster(i) else xs(i))
350350
i += 1
351351
sum
352352
```
353-
That would avoid the boxing at the cost of a type test in the computation of `faster` and a null test in the call of `apply`. The single type test would be amortized over possibly many calls in the loop. We could do even better by generating a bit more code, splitting the whole loop:
353+
That would avoid the boxing at the cost of a type test in the computation of `faster` and a null test in the call of `apply`. The type test would be amortized over possibly many calls in the loop. We could do even better by generating a bit more code, splitting the whole loop:
354354
```scala
355355
def sumElems(xs: Vector[Int]): Int =
356356
val faster: faster.Vector[Int] | Null = xs match
@@ -373,7 +373,7 @@ The example has shown that it is possible to have code over possibly specialized
373373
The boilerplate could be generated automatically by an optimization phase in the compiler. Essentially when compiling methods that take parameters whose type is a class
374374
that's annotated with `specializedBy`, we can do the path splitting automatically in an optimization step. The optimization would first analyze the body of the method to decide which path splitting strategy to use.
375375

376-
I believe the three steps I have outlined could overcome most of the performance penalties imposed by existing unspecialized class hierarchies like collections, making their performance comparable to languages that use global monomorphization.
376+
I believe the three tweaks I have outlined could overcome most of the performance penalties imposed by existing unspecialized class hierarchies like collections, making their performance comparable to languages that use global monomorphization.
377377

378378
## Going Further: Hand-written Specializations
379379

0 commit comments

Comments
 (0)