-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a custom collection implementation in the AST:
`ConstArray` is a collection-like wrapper for an Array, similar to the standard mutable `ArrayBuffer` but immutable. For performance reasons it does not inherit any collection traits but it offers a similar API. The changes in this commit reduce the measured query compilation times in `CompilerBenchmark`by about 25%. It would be possible to take this one step further by making ConstArray a value class, which provides a further measurable performance improvement. However, a value class cannot currently implement proper equality semantics, thus making such a collection-like class much harder to use.
- Loading branch information
Showing
44 changed files
with
838 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
package slick.ast | ||
|
||
import slick.util.ConstArray | ||
|
||
/** Represents an Insert operation. */ | ||
final case class Insert(tableSym: TermSymbol, table: Node, linear: Node) extends BinaryNode with DefNode { | ||
type Self = Insert | ||
def left = table | ||
def right = linear | ||
override def childNames = Vector("table "+tableSym, "linear") | ||
def generators = Vector((tableSym, table)) | ||
def generators = ConstArray((tableSym, table)) | ||
def rebuild(l: Node, r: Node) = copy(table = l, linear = r) | ||
def rebuildWithSymbols(gen: IndexedSeq[TermSymbol]) = copy(tableSym = gen(0)) | ||
def rebuildWithSymbols(gen: ConstArray[TermSymbol]) = copy(tableSym = gen(0)) | ||
def withInferredType(scope: Type.Scope, typeChildren: Boolean): Self = { | ||
val table2 = table.infer(scope, typeChildren) | ||
val lin2 = linear.infer(scope + (tableSym -> table2.nodeType), typeChildren) | ||
withChildren(Vector(table2, lin2)) :@ (if(!hasType) lin2.nodeType else nodeType) | ||
withChildren(ConstArray[Node](table2, lin2)) :@ (if(!hasType) lin2.nodeType else nodeType) | ||
} | ||
override def getDumpInfo = super.getDumpInfo.copy(mainInfo = "") | ||
} | ||
|
||
/** A column in an Insert operation. */ | ||
final case class InsertColumn(children: IndexedSeq[Node], fs: FieldSymbol, buildType: Type) extends Node with SimplyTypedNode { | ||
final case class InsertColumn(children: ConstArray[Node], fs: FieldSymbol, buildType: Type) extends Node with SimplyTypedNode { | ||
type Self = InsertColumn | ||
protected[this] def rebuild(ch: IndexedSeq[Node]) = copy(children = ch) | ||
protected[this] def rebuild(ch: ConstArray[Node]) = copy(children = ch) | ||
override def getDumpInfo = super.getDumpInfo.copy(mainInfo = fs.toString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.