From a729b9b4c3d7844a7d44934bf3365f92633c0a60 Mon Sep 17 00:00:00 2001 From: tomlu Date: Thu, 8 Feb 2018 15:32:00 -0800 Subject: Replace path implementation. Path and PathFragment have been replaced with String-based implementations. They are pretty similar, but each method is dissimilar enough that I did not feel sharing code was appropriate. A summary of changes: PATH ==== * Subsumes LocalPath (deleted, its tests repurposed) * Use a simple string to back Path * Path instances are no longer interned; Reference equality will no longer work * Always normalized (same as before) * Some operations will now be slower, like instance compares (which were previously just a reference check) * Multiple identical paths will now consume more memory since they are not interned PATH FRAGMENT ============= * Use a simple string to back PathFragment * No more segment arrays with interned strings * Always normalized * Remove isNormalized * Replace some isNormalizied uses with containsUpLevelReferences() to check if path fragments try to escape their scope * To check if user input is normalized, supply static methods on PathFragment to validate the string before constructing a PathFragment * Because PathFragments are always normalized, we have to replace checks for literal "." from PathFragment#getPathString to PathFragment#getSafePathString. The latter returns "." for the empty string. * The previous implementation supported efficient segment semantics (segment count, iterating over segments). This is now expensive since we do longer have a segment array. ARTIFACT ======== * Remove Path instance. It is instead dynamically constructed on request. This is necessary to avoid this CL becoming a memory regression. RELNOTES: None PiperOrigin-RevId: 185062932 --- .../google/devtools/build/lib/windows/WindowsSubprocessFactory.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java') diff --git a/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java index a69884066c..af591cc7e8 100644 --- a/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java +++ b/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java @@ -83,9 +83,7 @@ public class WindowsSubprocessFactory implements SubprocessFactory { // If it's not absolute, then it cannot be longer than MAX_PATH, since MAX_PATH also limits the // length of file names. PathFragment argv0fragment = PathFragment.create(argv0); - return (argv0fragment.isAbsolute()) - ? argv0fragment.normalize().getPathString().replace('/', '\\') - : argv0; + return (argv0fragment.isAbsolute()) ? argv0fragment.getPathString().replace('/', '\\') : argv0; } private String getRedirectPath(StreamAction action, File file) { -- cgit v1.2.3