Don't use 'current' if 'from' is not relative.

R=rnystrom@google.com
BUG=

Review URL: https://codereview.chromium.org//937683002
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b36faed..e5f7b44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.3.3
+
+* Performance improvement in `Context.relative` - don't call `current` if `from`
+  is not relative.
+
 ## 1.3.2
 
 * Fix some analyzer hints.
diff --git a/lib/src/context.dart b/lib/src/context.dart
index a3efd95..c2fe48d 100644
--- a/lib/src/context.dart
+++ b/lib/src/context.dart
@@ -324,7 +324,13 @@
   /// "/", no path can be determined. In this case, a [PathException] will be
   /// thrown.
   String relative(String path, {String from}) {
-    from = from == null ? current : this.join(current, from);
+    // Avoid calling [current] since it is slow and calling join() when
+    // [from] is absolute does nothing.
+    if (from == null) {
+      from = current;
+    } else if (this.isRelative(from) || this.isRootRelative(from)) {
+      from = this.join(current, from);
+    }
 
     // We can't determine the path from a relative path to an absolute path.
     if (this.isRelative(from) && this.isAbsolute(path)) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 4974049..b4df1b6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: path
-version: 1.3.2
+version: 1.3.3
 author: Dart Team <misc@dartlang.org>
 description: >
  A string-based path manipulation library. All of the path operations you know
diff --git a/test/relative_test.dart b/test/relative_test.dart
index 4523c8d..57a9046 100644
--- a/test/relative_test.dart
+++ b/test/relative_test.dart
@@ -31,7 +31,7 @@
   var isRelative = (context.current == '.');
   // Cases where the arguments are absolute paths.
   expectRelative(result, pathArg, fromArg) {
-    expect(context.normalize(result), context.relative(pathArg, from: fromArg));
+    expect(context.relative(pathArg, from: fromArg), context.normalize(result));
   }
 
   expectRelative('c/d', '${prefix}a/b/c/d', '${prefix}a/b');