1. Miki Tebeka
  2. snowball

Commits

Miki Tebeka  committed 9f67ac6

List -> LangList and once in init

  • Participants
  • Parent commits 88f7d1f
  • Branches default

Comments (0)

Files changed (3)

File ChangeLog

View file
  • Ignore whitespace
-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

File snowball.go

View file
  • Ignore whitespace
 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
+}

File snowball_test.go

View file
  • Ignore whitespace
 )
 
 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