-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance and memory by caching XML Schema / DTD
Fixes #534 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
802ce50
commit 22ae728
Showing
4 changed files
with
470 additions
and
41 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...l/src/main/java/org/eclipse/lsp4xml/extensions/contentmodel/model/FileChangedTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.eclipse.lsp4xml.extensions.contentmodel.model; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.attribute.FileTime; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class FileChangedTracker { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(FileChangedTracker.class.getName()); | ||
|
||
private final Path file; | ||
private FileTime lastModified; | ||
|
||
public FileChangedTracker(Path file) { | ||
this.file = file; | ||
try { | ||
lastModified = Files.getLastModifiedTime(file); | ||
} catch (IOException e) { | ||
LOGGER.log(Level.SEVERE, "Get last modified time failed", e); | ||
} | ||
} | ||
|
||
public boolean isDirty() { | ||
try { | ||
if (!Files.exists(file)) { | ||
// This case occurs when user delete the XML Schema / DTD file | ||
return true; | ||
} | ||
FileTime currentLastMofied = Files.getLastModifiedTime(file); | ||
if (!currentLastMofied.equals(lastModified)) { | ||
lastModified = currentLastMofied; | ||
return true; | ||
} | ||
} catch (IOException e) { | ||
LOGGER.log(Level.SEVERE, "Get last modified time failed", e); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.