Miki Tebeka avatar Miki Tebeka committed 9f67ac6

List -> LangList and once in init

Comments (0)

Files changed (3)

-2013-04-05 version 0.1.3
+2013-04-05 version 0.2.0
     * Fix possible memory leak
+    * List -> LangList (and done once in init)
 
 2012-12-06 version 0.1.2
     * Free memory
 import "C"
 
 const (
-	Version = "0.1.3"
+	Version = "0.2.0"
 )
 
 // Stemmer structure
 	return string(buf)
 }
 
+var langList []string
+
 // List returns the list of languages supported by snowball
-func List() []string {
-	names := []string{}
-
+func init() {
 	// We don't need to free since sb_stemmer_list return pointer to static variable
 	cp := uintptr(unsafe.Pointer(C.sb_stemmer_list()))
 	size := unsafe.Sizeof(uintptr(0))
 		if len(name) == 0 {
 			break
 		}
-		names = append(names, name)
+		langList = append(langList, name)
 		cp += size
 	}
-	return names
 }
+
+func LangList() []string {
+	return langList
+}
 )
 
 func TestList(t *testing.T) {
-	if len(List()) == 0 {
+	if len(LangList()) == 0 {
 		t.Fatal("No langs")
 	}
 }
 
 func TestListEnglish(t *testing.T) {
 	found := false
-	for _, v := range List() {
+	for _, v := range LangList() {
 		if v == "english" {
 			found = true
 			break
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.