From fd27cc3435fcdd078553d4ed64c9bb23e0b5be8c Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Tue, 1 May 2018 21:11:04 +0000 Subject: [PATCH] Don't store bytes in the file cache. We needed bytes only to get their length. This CL replaces it to using the content (String) length. This should help to fix heap usage regression. R=paulberry@google.com Change-Id: I4d58e91987db21233a71ca600eea8fae3fb38346 Reviewed-on: https://dart-review.googlesource.com/53243 Reviewed-by: Paul Berry Commit-Queue: Konstantin Shcheglov --- pkg/analyzer/lib/src/dart/analysis/driver.dart | 2 +- pkg/analyzer/lib/src/dart/analysis/file_state.dart | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart index 8085a6be842..f8b16482d22 100644 --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart @@ -95,7 +95,7 @@ class AnalysisDriver implements AnalysisDriverGeneric { /** * The version of data format, should be incremented on every format change. */ - static const int DATA_VERSION = 57; + static const int DATA_VERSION = 58; /** * The number of exception contexts allowed to write. Once this field is diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart index b82ab398212..d7751001416 100644 --- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart +++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart @@ -403,12 +403,10 @@ class FileState { * Return `true` if the API signature changed since the last refresh. */ bool refresh({bool allowCached: false}) { - List contentBytes; { var rawFileState = _fsState._fileContentCache.get(path, allowCached); _content = rawFileState.content; _exists = rawFileState.exists; - contentBytes = rawFileState.contentBytes; _contentHash = rawFileState.contentHash; } @@ -416,7 +414,6 @@ class FileState { { ApiSignature signature = new ApiSignature(); signature.addUint32List(_fsState._salt); - signature.addInt(contentBytes.length); signature.addString(_contentHash); _unlinkedKey = '${signature.toHex()}.unlinked'; } @@ -974,11 +971,9 @@ class _FileContent { final String path; final bool exists; final String content; - final List contentBytes; final String contentHash; - _FileContent(this.path, this.exists, this.content, this.contentBytes, - this.contentHash); + _FileContent(this.path, this.exists, this.content, this.contentHash); } /** @@ -1024,7 +1019,7 @@ class _FileContentCache { List contentHashBytes = md5.convert(contentBytes).bytes; String contentHash = hex.encode(contentHashBytes); - file = new _FileContent(path, exists, content, contentBytes, contentHash); + file = new _FileContent(path, exists, content, contentHash); _pathToFile[path] = file; } return file;