-
Notifications
You must be signed in to change notification settings - Fork 20
Refactor file handling #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This PR gives a significant speedup (6.5s to 5.0s for ck3) and I can't figure out why. |
|
There's something wrong with the loca parsing, which is probably why it's faster. There are no reports about localization files in the output. |
|
I got as far as discovering that the dummy localization files from |
|
Oop, I'll track that down. Any design concerns? |
|
I was concerned about possible slowdown due to all the locking around In one of my early designs before the PathTable, I tried to make pathname in Loc an Arc, and it resulted in significant slowdown. Other than that, I'll have to read it a few more times. |
|
I've made sure that the Arc is only cloned when needed. Most places pass the file entry around as My most recent tests show very similar performance to before this change. Some area's have improved (notably |
8d879e4 to
0465025
Compare
Clean up Fileset construction and fix bug Don't bother normalising paths fix tests
0465025 to
d66848f
Compare
amtep
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly comment changes, but the use of PathIdx::UNTRACKED needs to be revisited. The entries that use it can definitely have errors reported. The launcher file via errors emitted by the parser, and the internal strings sometimes have errors that I need to fix. It would be awkward to not get those errors.
| /// and examine the mod files. | ||
| /// | ||
| /// `mod_root` is the path to the mod files. The config file will also be looked for there. | ||
| /// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function comment needs updating now
| #[derive(Debug)] | ||
| pub struct FileContent { | ||
| /// Full content of the file. It must never be moved or modified. | ||
| // full: Cow<'static, str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray commented-out line
| impl FileContent { | ||
| pub fn new(mut s: String) -> Self { | ||
| s.shrink_to_fit(); | ||
| //Self { full: Cow::from(s), lines: OnceLock::new() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray commented-out line
| } | ||
|
|
||
| pub fn new_static(s: &'static str) -> Self { | ||
| //Self { full: Cow::from(s), lines: OnceLock::new() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray commented-out line
|
|
||
| impl FileDb { | ||
| /// Gets a reference to a file entry. | ||
| /// If the fileset has not been finalized, a new entry will be created and returned if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If the fileset has not been finalized" is no longer accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, "gets a reference" was a bit confusing because I read it as "receives" but you meant "fetches"
| } | ||
| } | ||
|
|
||
| /// # Panics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
| let msg = format!("file in unexpected directory {}", dirname.display()); | ||
| let info = format!("did you mean common/{} ?", dirname.display()); | ||
| err(ErrorKey::Filename).msg(msg).info(info).loc(entry).push(); | ||
| err(ErrorKey::Filename).msg(msg).info(info).loc(&**entry).push(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the &** still needed? You added a From for the Arc
| } | ||
|
|
||
| /// # Panics | ||
| /// Will panic if a lock on self.used can not be obtained |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is inaccurate :) See above
| self.db.files.entry(entry.path().to_path_buf()).or_insert_with(|| { | ||
| FileEntry::new(inner_path.to_path_buf(), kind, entry.path().to_path_buf()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling entry.path().to_path_buf() twice here
| let content = leak(content); | ||
| store_source_file(entry.fullpath().to_path_buf(), &content[offset..]); | ||
| parse_pdx(entry, &content[offset..], parser) | ||
| pub fn parse_pdx_file(entry: &FileEntry, parser: &ParserMemory) -> Option<Block> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this function can be removed and the callers just call parse_pdx
|
Btw I've been thinking that the internal pdx script may have been a mistake and a table-based approach would be better. But getting rid of them is a longer term task. (Reasoning: errors in the pdx script cause runtime failures, which I mjght not catch before release. This has happened once.) |
Goals