Skip to content

Commit caae59a

Browse files
committed
cleanup
1 parent d6254f2 commit caae59a

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

src/typegraph/optimize/src/dedup.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ impl DedupEngine {
158158
"function".hash(&mut hasher);
159159
// TODO do we need to deduplication functions??
160160
idx.hash(&mut hasher);
161-
// self.hash_type(data.input.into()).hash(&mut hasher);
162-
// self.hash_type(data.output.into()).hash(&mut hasher);
163-
// if let Some(pt) = data.
164161
}
165162

166163
N::Any { .. } => unreachable!(),

src/typegraph/optimize/src/kosaraju.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ impl KosarajuOne {
3434
}
3535

3636
fn visit(&mut self, idx: TypeIdx) {
37-
if self.is_visited(idx) {
38-
} else {
37+
if !self.is_visited(idx) {
3938
self.set_visited(idx);
4039
for v in self.tg.out_neighbours(&idx) {
4140
self.visit(v);

tools/tree-view-web.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,25 @@ if (tgs.length === 0) {
8181
const byName: Map<string, TypeGraphDS> = new Map();
8282

8383
for (const tg of tgs) {
84+
const name = tg.types[0].title;
85+
if (byName.has(name)) {
86+
console.log(
87+
`[warn] Duplicate typegraph name '${name}'. The older one will be dropped`,
88+
);
89+
}
8490
byName.set(tg.types[0].title, tg);
8591
}
8692

8793
const router = new Router();
8894

89-
const fsCache: Map<string, string> = new Map();
95+
const fsCache: Map<string, Uint8Array> = new Map();
9096

9197
async function getDistFile(path: string) {
9298
const cached = fsCache.get(path);
9399
if (cached != null) {
94100
return cached;
95101
}
96-
const value = await Deno.readTextFile(
102+
const value = await Deno.readFile(
97103
`${projectDir}/tools/tree/dist/${path}`,
98104
);
99105
fsCache.set(path, value);
@@ -139,8 +145,19 @@ router.get("/api/typegraphs/:tgName/types/:typeIdx", (ctx) => {
139145
ctx.response.body = `typegraph "${ctx.params.tgName}" not found`;
140146
ctx.response.status = Status.NotFound;
141147
} else {
142-
ctx.response.body = tg.types[+ctx.params.typeIdx];
143-
ctx.response.type = "json";
148+
const typeIdx = +ctx.params.typeIdx;
149+
if (Number.isNaN(typeIdx)) {
150+
ctx.response.body = `invalid type index "${ctx.params.typeIdx}"`;
151+
ctx.response.status = Status.BadRequest;
152+
}
153+
const typeNode = tg.types[typeIdx];
154+
if (typeNode == null) {
155+
ctx.response.body = `type index out of bounds #${typeIdx}`;
156+
ctx.response.status = Status.NotFound;
157+
} else {
158+
ctx.response.body = tg.types[+ctx.params.typeIdx];
159+
ctx.response.type = "json";
160+
}
144161
}
145162
});
146163

tools/tree/dist/assets/index-B7TWQuis.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)