ludic.i18n: a language's lookups kept once read; switching back restores them
i18n_use re-read and re-parsed the .po on every change of language (ev_SettingsChanged, SetLang) and dropped the old tables for good: the play of 22 minutes left lines_of 650 KB, fs_read_text 409 KB, PoEntry 113 KB and unquote 273 KB unreachable, and three of its @alloc_ok sites were declared but unbounded. Each language's tables are now filed by index once built (tables.ludic, I18nTables) and put back by reference; a new probe (i18n_init) or a different file for a code (lang_add) reads it again. Test: a language switched back to is its kept tables, not its file read again; a new probe reads it (9 tests pass). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
28ad6f62ea
commit
1667d7f16e
6 changed files with 112 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ export function i18n_init(i18n_st: mut I18nState) -> void {
|
|||
i18n_st.names = new []string
|
||||
i18n_st.paths = new []string
|
||||
i18n_st.fonts = new []string
|
||||
i18n_st.tabs = new []I18nTables
|
||||
lang_add(i18n_st, "en", "English", "", "")
|
||||
let idx = Fs.read_text(i18n_st.lang_dir + "/languages.txt")
|
||||
if idx != null {
|
||||
|
|
@ -37,6 +38,7 @@ function lang_add(i18n_st: mut I18nState, code: string, name: string, path: stri
|
|||
i18n_st.names[i] = name
|
||||
i18n_st.paths[i] = path
|
||||
i18n_st.fonts[i] = font
|
||||
if tables_have(i18n_st, i) { i18n_st.tabs[i] = null } # another file for it: read that one next time
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue