diff options
author | Martin Odersky <odersky@gmail.com> | 2014-02-20 10:43:54 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-02-21 18:42:50 +0100 |
commit | d8f1fa55af2d832c07d89abaf9ecffc44c6572f8 (patch) | |
tree | b5eca43019c12d9e1845c7ddaec65bc9d8289ff0 /src/dotty/tools/dotc/core/Types.scala | |
parent | 2d3181ab808145fbdbe657740b41c16e82db7c87 (diff) | |
download | dotty-d8f1fa55af2d832c07d89abaf9ecffc44c6572f8.tar.gz dotty-d8f1fa55af2d832c07d89abaf9ecffc44c6572f8.tar.bz2 dotty-d8f1fa55af2d832c07d89abaf9ecffc44c6572f8.zip |
Performance tuning: Inline TypeAlias case for hot maps.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index aab70a61b..9a7fc59b8 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1871,6 +1871,11 @@ object Types { if ((lo eq this.lo) && (hi eq this.hi) && (variance == this.variance)) this else TypeBounds(lo, hi, variance) + /** pre: this is a type alias */ + def derivedTypeAlias(tp: Type, variance: Int = this.variance)(implicit ctx: Context) = + if (lo eq tp) this + else TypeAlias(tp, variance) + def contains(tp: Type)(implicit ctx: Context) = lo <:< tp && tp <:< hi def & (that: TypeBounds)(implicit ctx: Context): TypeBounds = @@ -2124,8 +2129,9 @@ object Types { if (lo eq hi) { val saved = variance variance = variance * tp.variance - val lo1 = try this(lo) finally variance = saved - tp.derivedTypeBounds(lo1, lo1) + val lo1 = this(lo) + variance = saved + tp.derivedTypeAlias(lo1) } else { variance = -variance val lo1 = this(lo) @@ -2247,8 +2253,9 @@ object Types { if (lo eq hi) { val saved = variance variance = variance * bounds.variance - try this(x, lo) - finally variance = saved + val result = this(x, lo) + variance = saved + result } else { variance = -variance |