From 45b3f3333ff8812907d939768bf5153c51c5679a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 14:01:52 +0400 Subject: [PATCH] win32cache: less memory --- .../openapi/vfs/impl/win32/Win32FsCache.java | 32 ++++++++++--------- .../vfs/impl/win32/Win32LocalFileSystem.java | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java index 5612b530f0f6..d135f39c4fb7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vfs.impl.win32; +import com.intellij.openapi.util.io.FileAttributes; import com.intellij.openapi.util.io.win32.FileInfo; import com.intellij.openapi.util.io.win32.IdeaWin32; import com.intellij.openapi.vfs.VirtualFile; @@ -34,19 +35,19 @@ import java.util.Map; */ class Win32FsCache { private final IdeaWin32 myKernel = IdeaWin32.getInstance(); - private Reference> myCache; + private Reference> myCache; void clearCache() { myCache = null; } @NotNull - private Map getMap() { - Reference> cache = myCache; - Map map = cache == null ? null : cache.get(); + private Map getMap() { + Reference> cache = myCache; + Map map = cache == null ? null : cache.get(); if (map == null) { - map = new THashMap(); - myCache = new SoftReference>(map); + map = new THashMap(); + myCache = new SoftReference>(map); } return map; } @@ -60,10 +61,10 @@ class Win32FsCache { if (!path.endsWith("/")) path += "/"; List names = new ArrayList(fileInfo.length); - Map map = getMap(); + Map map = getMap(); for (FileInfo info : fileInfo) { String name = info.getName(); - map.put(path + name, info); + map.put(path + name, info.toFileAttributes()); names.add(name); } @@ -71,17 +72,18 @@ class Win32FsCache { } @Nullable - FileInfo getInfo(@NotNull VirtualFile file) { + FileAttributes getAttributes(@NotNull VirtualFile file) { String path = file.getPath(); - Map map = getMap(); - FileInfo info = map.get(path); - if (info == null) { - info = myKernel.getInfo(path); + Map map = getMap(); + FileAttributes attributes = map.get(path); + if (attributes == null) { + FileInfo info = myKernel.getInfo(path); if (info == null) { return null; } - map.put(path, info); + attributes = info.toFileAttributes(); + map.put(path, attributes); } - return info; + return attributes; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java index c8353d5c94d5..3bbba55e0992 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java @@ -16,7 +16,6 @@ package com.intellij.openapi.vfs.impl.win32; import com.intellij.openapi.util.io.FileAttributes; -import com.intellij.openapi.util.io.win32.FileInfo; import com.intellij.openapi.util.io.win32.IdeaWin32; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase; @@ -60,8 +59,7 @@ public class Win32LocalFileSystem extends LocalFileSystemBase { @Override public FileAttributes getAttributes(@NotNull VirtualFile file) { - final FileInfo fileInfo = myFsCache.getInfo(file); - return fileInfo != null ? fileInfo.toFileAttributes() : null; + return myFsCache.getAttributes(file); } @NotNull