Skip to content

Commit

Permalink
use slightly slower code to deal with the fact that many apps put sem…
Browse files Browse the repository at this point in the history
…i-colons on clockinfo/settings that are supposed to be evaluated
  • Loading branch information
gfwilliams committed Oct 24, 2024
1 parent 1ec8fba commit 9185793
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/boot/bootupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let outputFile = (dst,src,pre,post) => {"ram";
if (src.endsWith("clkinfo.js") && f[0]!="(") {
/* we shouldn't have to do this but it seems sometimes (sched 0.28) folks have
used libraries which get added into the clockinfo, and we can't use them directly
to we have to rever back to eval. */
to we have to revert back to eval */
f = `eval(require('Storage').read(${E.toJS(src)}))`;
}
if (dst) {
Expand Down Expand Up @@ -195,7 +195,7 @@ let ciFiles = require("Storage").list(/\.clkinfo\.js$/);
let ci = `// Made by bootupdate.js\n`;
if (DEBUG) ci+="var _tm=Date.now();";
outputFileComplete = (dst,fn) => {
outputFile(dst,fn,"try{let a=",`(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${E.toJS(fn)},e,e.stack)}\n`);
outputFile(dst,fn,"try{let fn=",`;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${E.toJS(fn)},e,e.stack)}\n`);
};
fileOffset = ci.length;
ciFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
Expand Down

2 comments on commit 9185793

@thyttan
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it would be worth our while, I could go through clockinfos and settings to remove trailing semicolons? So we can do it the faster way here.

In that case, I guess we should add to the sanitychecker checks and instructions re not adding semicolons to those types of files?

@gfwilliams
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're happy to do that, that would be really cool. I actually did already add it to sanitycheck, I was just wondering whether to commit it or not - but I have now done so :) It's not like it really adds that much delay to loading, it's just a slight annoyance.

The big potential issue we have (the first part of this commit where the comment is) is when clockinfo/etc use libraries that then get added to the start of the file with Modules.addCached and have to be evaled. Having to fall back to eval and a file load in those cases (like sched.clkinfo.js) really does add a decent amount of delay.

The sane option there might be to modify EspruinoTools to allow it to just return the extra modules needed in a list, which could then be written direct to storage, but I guess it might be possible to parse out the Modules.addCached line from within bootupdate and put it at the start of the clkinfocache file

Please sign in to comment.