-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: decrease memory footprint and binary size (#11)
* feat: internal map now use pointers to decrease memory footprint. dicts/data.go split into multiple orphaned packages, to decrease import size. main.go renamed to golem.go Italian added. Contributors Hall of Fame added * fix: solved TODO in dicts/cmd and completed README * fix: regenerated files with code-comment
- Loading branch information
Showing
19 changed files
with
1,681 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ data | |
*.out | ||
*.test | ||
pprof | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"text/template" | ||
) | ||
|
||
type data struct { | ||
Locale string | ||
} | ||
|
||
// This is a code generator for language pack constructors. Check dicts/en/pack.go for an example | ||
func main() { | ||
var d data | ||
flag.StringVar(&d.Locale, "locale", "", "The locale abbreviation this language pack is generated for") | ||
flag.Parse() | ||
|
||
t := template.Must(template.New("pack").Parse(packTemplate)) | ||
t.Execute(os.Stdout, d) | ||
} | ||
|
||
var packTemplate = ` // Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package {{.Locale}} | ||
const locale = "{{.Locale}}" | ||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for {{.Locale}} | ||
type LanguagePack struct { | ||
} | ||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
` |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package de | ||
|
||
const locale = "de" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for de | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package en | ||
|
||
const locale = "en" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for en | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package es | ||
|
||
const locale = "es" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for es | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package fr | ||
|
||
const locale = "fr" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for fr | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package it | ||
|
||
const locale = "it" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for it | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Code generated by golem/dicts/cmd/generate_pack.go DO NOT EDIT | ||
package sv | ||
|
||
const locale = "sv" | ||
|
||
// LanguagePack is an implementation of the generic golem.LanguagePack interface for sv | ||
type LanguagePack struct { | ||
} | ||
|
||
// NewPackage creates a language pack | ||
func NewPackage() *LanguagePack { | ||
return &LanguagePack{} | ||
} | ||
|
||
// GetResource returns the dictionary of lemmatized words | ||
func (l *LanguagePack) GetResource() ([]byte, error) { | ||
return Asset("data/" + locale) | ||
} | ||
|
||
// GetLocale returns the language name | ||
func (l *LanguagePack) GetLocale() string { | ||
return locale | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.