This page is no longer maintained — Please continue to the home page at www.scala-lang.org

I am missing List.indexOf

No replies
hrj
Joined: 2008-09-23,
User offline. Last seen 4 years 3 weeks ago.

Hi,

The implementation of Seq.indexOf is noticably unoptimal for List (in my benchmark). I feel it should be overriden in List with a tailored one.

I have attached a sample implementation and my benchmark. Here is the output:

$ scala -savecompiled -optimise test.scala
For default implementation: 23086 ms
For optimised implementation: 2359 ms
Results match: true

My configuration is:
Scala 2.7.3
java version "1.6.0_0"
IcedTea6 1.4 (fedora-9.b14.fc10-i386) Runtime Environment (build 1.6.0_0-b14)
OpenJDK Client VM (build 14.0-b08, mixed mode)

cheers,
Harshad

PS. In a personal project (which I can't share), a similarly tailored version of indexOf saved execution time by a factor of about 60!

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland