Skip to content

Commit e93beb3

Browse files
author
Lucas Hosseini
committed
[skc] Merge fileTimeDir into allFilesDir.
1 parent ae10b81 commit e93beb3

2 files changed

Lines changed: 17 additions & 40 deletions

File tree

skiplang/compiler/src/compile.sk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ fun getOrInitializeBackend(
204204
};
205205

206206
_ = context.mkdir(x ~> x, x ~> x, FileCache.fileDirName);
207-
_ = context.mkdir(x ~> x, x ~> x, FileCache.fileTimeDirName);
208207
_ = context.mkdir(x ~> x, x ~> x, FileCache.allFilesDirName);
209208
backendDir = context.mkdir(
210209
SKStore.IID::keyType,

skiplang/compiler/src/skipParse.sk

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ const fileDir: SKStore.EHandle<
2222
fileDirName,
2323
);
2424

25-
class InputPackage(name: ?String, srcs: Array<String>) extends SKStore.File
25+
class InputPackage(
26+
name: ?String,
27+
srcs: Array<(String, Int)>,
28+
) extends SKStore.File
2629

2730
// Contains the paths of all source files the analysis of which has
2831
// been kept so far.
@@ -35,22 +38,10 @@ const allFilesDir: SKStore.EHandle<SKStore.IID, InputPackage> = SKStore.EHandle(
3538
allFilesDirName,
3639
);
3740

38-
const fileTimeDirName: SKStore.DirName = SKStore.DirName::create(
39-
"/fileTimeCache/",
40-
);
41-
const fileTimeDir: SKStore.EHandle<
42-
SKStore.SID,
43-
SKStore.IntFile,
44-
> = SKStore.EHandle(
45-
SKStore.SID::keyType,
46-
SKStore.IntFile::type,
47-
fileTimeDirName,
48-
);
49-
5041
fun pkgDelta(
5142
old_srcs: Array<(String, Int)>,
5243
new_srcs: Array<(String, Int)>,
53-
): (Array<(String, Int)>, Array<(String, Int)>, Array<(String, Int)>) {
44+
): (Array<String>, Array<String>, Array<String>) {
5445
added_files = mutable Vector[];
5546
modified_files = mutable Vector[];
5647
deleted_files = mutable Vector[];
@@ -60,16 +51,16 @@ fun pkgDelta(
6051
old_srcs.find(s -> s.i0 == src) match {
6152
| Some((_, old_mtime)) ->
6253
if (mtime != old_mtime) {
63-
modified_files.push((src, mtime))
54+
modified_files.push(src)
6455
}
65-
| None() -> added_files.push((src, mtime))
56+
| None() -> added_files.push(src)
6657
}
6758
};
6859

6960
// FIXME: This is O(n^2).
70-
for ((src, mtime) in old_srcs) {
61+
for ((src, _) in old_srcs) {
7162
if (!new_srcs.any(s -> s.i0 == src)) {
72-
deleted_files.push((src, mtime))
63+
deleted_files.push(src)
7364
}
7465
};
7566

@@ -110,14 +101,7 @@ fun writeFiles(
110101
// Files kept in the previous run.
111102
old_files = mutable Map[];
112103
for (pkg in allFilesDir.unsafeGetArray(context, SKStore.IID(0))) {
113-
srcs_with_mtime = pkg.srcs
114-
.map(fn -> {
115-
key = formatPkgSrc(pkg.name, fn);
116-
mtime = fileTimeDir.unsafeGetArray(context, SKStore.SID(key))[0].value;
117-
(fn, mtime)
118-
})
119-
.collect(Array);
120-
old_files.set(pkg.name, srcs_with_mtime)
104+
old_files.set(pkg.name, pkg.srcs)
121105
};
122106

123107
stale_pkgs = mutable Vector<?String>[];
@@ -132,7 +116,7 @@ fun writeFiles(
132116
) {
133117
pkgDelta(old_files[pkg_opt], srcs.map(src -> (src.i0, src.i1)));
134118
} else {
135-
(srcs.map(src -> (src.i0, src.i1)), Array[], Array[])
119+
(srcs.map(src -> src.i0), Array[], Array[])
136120
};
137121

138122
if (
@@ -145,43 +129,37 @@ fun writeFiles(
145129
stale_pkgs.push(pkg_opt);
146130

147131
// Update added/modified files.
148-
for ((src_path, src_mtime) in added_files.concat(modified_files)) {
132+
for (src_path in added_files.concat(modified_files)) {
149133
key = formatPkgSrc(pkg_opt, src_path);
150134
// FIXME: This is O(n).
151135
src_contents = srcs.find(src ~> src.i0 == src_path).fromSome().i2;
152-
fileTimeDir.writeArray(
153-
context,
154-
SKStore.SID(key),
155-
Array[SKStore.IntFile(src_mtime)],
156-
);
157136
fileDir.writeArray(
158137
context,
159138
SKStore.SID(key),
160139
Array[SKStore.StringFile(src_contents)],
161140
)
162141
};
163142
// Invalidate deleted files.
164-
for ((src_path, _) in deleted_files) {
143+
for (src_path in deleted_files) {
165144
key = formatPkgSrc(pkg_opt, src_path);
166145
fileDir.writeArray(
167146
context,
168147
SKStore.SID(key),
169148
Array[SKStore.StringFile("")],
170-
);
171-
fileTimeDir.writeArray(context, SKStore.SID(key), Array[])
149+
)
172150
}
173151
};
174152

175-
// Keep analysis for all non-stale packages.
176153
new_old_files = current_files
177-
.map((_, srcs) -> srcs.map(src -> src.i0))
154+
.map((_, srcs) -> srcs.map(src -> (src.i0, src.i1)))
178155
.clone();
156+
// Keep analysis for all non-stale packages.
179157
for (pkg_opt => srcs in old_files) {
180158
// FIXME: This is O(n).
181159
if (stale_pkgs.contains(pkg_opt)) {
182160
continue
183161
};
184-
new_old_files.set(pkg_opt, srcs.map(src -> src.i0).collect(Array))
162+
new_old_files.set(pkg_opt, srcs)
185163
};
186164

187165
allFilesDir.writeArray(

0 commit comments

Comments
 (0)