/*
 * Copyright 2017-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.facebook.buck.util.filesystem;

import com.google.devtools.build.lib.vfs.PathFragment;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;

/** Conversion utilities between Paths and PathFragments. */
public final class PathFragments {
  private PathFragments() {} // Utility class, do not instantiate.

  // NB: This code avoids invoking toString() on either Path or PathFragment instances which
  // may be long lived. For both classes, toString() results are cached in the object instance,
  // leading to excessive memory usage.

  /** Convert a Skylark PathFragment to a Java Path. */
  public static PathFragment pathToFragment(Path path) {
    return PathFragment.create(path.toString());
  }

  /** Convert a skylark PathFragment to a Path using the default filesystem. */
  public static Path fragmentToPath(PathFragment fragment) {
    return fragmentToPath(FileSystems.getDefault(), fragment);
  }

  /** Convert a skylark PathFragment to a Path. */
  public static Path fragmentToPath(FileSystem fileSystem, PathFragment fragment) {
    return fileSystem.getPath(fragment.toString());
  }
}

@@ -965,30 +965,146 @@
 %0A  /
-/ NB: This code a
+** Convert a Skylark PathFragment to a Java Path. */%0A  public static PathFragment pathToFragment(Path path) %7B%0A    // TODO(buckteam): A
 void
-s
  inv
@@ -1127,35 +1127,12 @@
  on 
-either Path or PathFragment
+Path
  ins
@@ -1143,21 +1143,16 @@
 es which
-%0A  //
  may be 
@@ -1166,26 +1166,15 @@
 ved.
- For both classes,
+%0A    //
  toS
@@ -1227,13 +1227,8 @@
 nce,
-%0A  //
  lea
@@ -1262,122 +1262,8 @@
 age.
-%0A%0A  /** Convert a Skylark PathFragment to a Java Path. */%0A  public static PathFragment pathToFragment(Path path) %7B
 %0A   

Update no longer valid comment.