Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
c5b20192
Commit
c5b20192
authored
24 years ago
by
Martin Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
Update from RoxenLocale
Rev: lib/modules/Locale.pmod/module.pmod:1.5
parent
6ae4fd5d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Locale.pmod/module.pmod
+51
-5
51 additions, 5 deletions
lib/modules/Locale.pmod/module.pmod
with
51 additions
and
5 deletions
lib/modules/Locale.pmod/module.pmod
+
51
−
5
View file @
c5b20192
...
...
@@ -8,9 +8,9 @@
//#define LOCALE_DEBUG_ALL
// project_name:project_path
private
mapping(string:string) projects;
static
mapping(string:string) projects;
// language:(project_name:project)
private
mapping(string:mapping(string:object)) locales;
static
mapping(string:mapping(string:object)) locales;
void create() {
projects=([]);
...
...
@@ -52,6 +52,9 @@ static class LanguageListObject {
timestamp = time(1);
}
string _sprintf() {
return sprintf("LanguageListObject(timestamp: %d, %O)", timestamp, languages);
}
}
array(string) list_languages(string project) {
...
...
@@ -100,10 +103,11 @@ array(string) list_languages(string project) {
class LocaleObject {
// key:string
private
mapping(string|int:string) bindings;
static
mapping(string|int:string) bindings;
// key:function
mapping(string:function) functions;
public
mapping(string:function) functions;
int timestamp;
constant is_locale=1;
void create(mapping(string|int:string) _bindings,
void|mapping(string:function) _functions) {
...
...
@@ -133,6 +137,23 @@ class LocaleObject {
return functions[f];
}
int estimate_size() {
int size=2*64+8; //Two mappings and a timestamp
foreach(indices(bindings), string|int id) {
size+=8;
if(stringp(id)) size+=strlen(id);
else size+=4;
size+=strlen(bindings[id]);
}
size+=32*sizeof(functions); // The actual functions are not included though...
size+=strlen( indices(functions)*"" );
return size;
}
string _sprintf() {
return sprintf("LocaleObject(timestamp: %d, bindings: %d, functions: %d)",
timestamp, sizeof(bindings), sizeof(functions) );
}
}
object get_object(string project, string lang) {
...
...
@@ -330,7 +351,7 @@ function call(string project, string lang, string name,
return f || [function]fb;
}
static
void clean_cache() {
void clean_cache() {
remove_call_out(clean_cache);
int t = time(1)-CLEAN_CYCLE;
foreach(indices(locales), string lang) {
...
...
@@ -347,6 +368,31 @@ static void clean_cache() {
call_out(clean_cache, CLEAN_CYCLE);
}
void flush_cache() {
#ifdef LOCALE_DEBUG
werror("Locale.flush_cache()\n");
#endif
locales=([]);
// We could throw away the projects too,
// but then things would probably stop working.
}
mapping cache_status() {
int size=0, lp=0;
foreach(values(locales), mapping l)
foreach(values(l), object o) {
if(!o->is_locale) continue;
lp++;
size+=o->estimate_size();
}
return (["bytes":size,
"languages":sizeof(locales),
"reg_proj":sizeof(projects),
"load_proj":lp,
]);
}
class DeferredLocale
{
static string project;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment