Use a more compact internal representation for FileSpan.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//706133002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/source_span@41591 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/source_span/CHANGELOG.md b/pkgs/source_span/CHANGELOG.md
index 04e4be2..e5190bc 100644
--- a/pkgs/source_span/CHANGELOG.md
+++ b/pkgs/source_span/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.0.1
+
+* Use a more compact internal representation for `FileSpan`.
+
 # 1.0.0
 
 This package was extracted from the
diff --git a/pkgs/source_span/lib/src/file.dart b/pkgs/source_span/lib/src/file.dart
index 0d2d6f6..5680733 100644
--- a/pkgs/source_span/lib/src/file.dart
+++ b/pkgs/source_span/lib/src/file.dart
@@ -73,7 +73,7 @@
   /// If [end] isn't passed, it defaults to the end of the file.
   FileSpan span(int start, [int end]) {
     if (end == null) end = length - 1;
-    return new FileSpan._(this, location(start), location(end));
+    return new FileSpan._(this, start, end);
   }
 
   /// Returns a location in [this] at [offset].
@@ -172,7 +172,7 @@
     }
   }
 
-  FileSpan pointSpan() => new FileSpan._(file, this, this);
+  FileSpan pointSpan() => new FileSpan._(file, offset, offset);
 }
 
 /// A [SourceSpan] within a [SourceFile].
@@ -187,14 +187,26 @@
   /// The [file] that [this] belongs to.
   final SourceFile file;
 
-  final FileLocation start;
-  final FileLocation end;
+  /// The offset of the beginning of the span.
+  ///
+  /// [start] is lazily generated from this to avoid allocating unnecessary
+  /// objects.
+  final int _start;
+
+  /// The offset of the end of the span.
+  ///
+  /// [end] is lazily generated from this to avoid allocating unnecessary
+  /// objects.
+  final int _end;
+
+  FileLocation get start => new FileLocation._(file, _start);
+  FileLocation get end => new FileLocation._(file, _end);
 
   String get text => file.getText(start.offset, end.offset);
 
-  FileSpan._(this.file, this.start, this.end) {
-    if (end.offset < start.offset) {
-      throw new ArgumentError('End $end must come after start $start.');
+  FileSpan._(this.file, this._start, this._end) {
+    if (_end < _start) {
+      throw new ArgumentError('End $_end must come after start $_start.');
     }
   }
 
@@ -222,8 +234,8 @@
           " \"${other.sourceUrl}\" don't match.");
     }
 
-    var start = min(this.start, other.start);
-    var end = max(this.end, other.end);
+    var start = math.min(this._start, other._start);
+    var end = math.max(this._end, other._end);
     return new FileSpan._(file, start, end);    
   }
 
diff --git a/pkgs/source_span/pubspec.yaml b/pkgs/source_span/pubspec.yaml
index 66e5811..ae1bfcf 100644
--- a/pkgs/source_span/pubspec.yaml
+++ b/pkgs/source_span/pubspec.yaml
@@ -1,6 +1,6 @@
 name: source_span
 
-version: 1.0.0
+version: 1.0.1
 author: Dart Team <misc@dartlang.org>
 description: A library for identifying source spans and locations.
 homepage: http://www.dartlang.org