Skip to content

SeqOps.indexOfSlice defaults to using this.tail even for sequences other than LinearSeq! #13171

@noresttherein

Description

@noresttherein

Scala version: 2.13.16

  1. Implementation of indexOfSlice in SeqOps is not overriden in IndexedSeqOps.
  2. Neither it is overriden in Vector or ArraySeq
  3. If either the argument's or this's knownSize is negative, the default implementation recursively calls this.tail.

Problem

The operation is needlessly expensive for anything but List, being even O(n^3) for ArraySeq!
This should be implemented using an iterator.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions