Commits

Paul Ruane committed 940208e

Slices now returned directly rather than as pointer.

Comments (0)

Files changed (6)

src/tmsu/commands/delete.go

 	error = db.DeleteTag(tag.Id)
 	if error != nil { return error }
 
-	for _, fileTag := range *fileTags {
+	for _, fileTag := range fileTags {
 		hasTags, error := db.AnyFileTagsForFile(fileTag.FileId)
 		if error != nil { return error }
 

src/tmsu/commands/export.go

 			return error
 		}
 
-		tagNames := make([]string, 0, len(*tags))
+		tagNames := make([]string, 0, len(tags))
 
-		for _, tag := range *tags {
+		for _, tag := range tags {
 			tagNames = append(tagNames, tag.Name)
 		}
 

src/tmsu/commands/merge.go

     fileTags, error := db.FileTagsByTagId(sourceTag.Id)
     if error != nil { return error }
 
-    for _, fileTag := range *fileTags {
+    for _, fileTag := range fileTags {
         destFileTag, error := db.FileTagByFileIdAndTagId(fileTag.FileId, destTag.Id)
         if error != nil { return error }
         if destFileTag != nil { continue }

src/tmsu/commands/tags.go

 	tags, error := db.Tags()
 	if error != nil { return error }
 
-	for _, tag := range *tags {
+	for _, tag := range tags {
 		fmt.Println(tag.Name)
 	}
 
             if error != nil { return error }
             if tags == nil { return nil }
 
-            for _, tag := range *tags {
+            for _, tag := range tags {
                 fmt.Println(tag.Name)
             }
 
             if error != nil { return error }
             if tags == nil { continue }
 
-            if len(*tags) > 0 {
+            if len(tags) > 0 {
                 fmt.Printf("%v: ", path)
 
-                for index, tag := range *tags {
+                for index, tag := range tags {
                     if index > 0 {
                         fmt.Print(" ")
                     }
     return nil
 }
 
-func (this TagsCommand) tagsForPath(db *Database, path string) (*[]Tag, error) {
+func (this TagsCommand) tagsForPath(db *Database, path string) ([]Tag, error) {
 	absPath, error := filepath.Abs(path)
 	if error != nil { return nil, error }
 
 	return this.connection.Close()
 }
 
-func (this Database) Tags() (*[]Tag, error) {
+func (this Database) Tags() ([]Tag, error) {
 	sql := `SELECT id, name
             FROM tag
             ORDER BY name`
 		tags = append(tags, Tag{id, name})
 	}
 
-	return &tags, nil
+	return tags, nil
 }
 
 func (this Database) TagByName(name string) (*Tag, error) {
 	return &Tag{id, name}, nil
 }
 
-func (this Database) TagsByFileId(fileId uint) (*[]Tag, error) {
+func (this Database) TagsByFileId(fileId uint) ([]Tag, error) {
 	sql := `SELECT id, name
             FROM tag
             WHERE id IN (
 		tags = append(tags, Tag{tagId, tagName})
 	}
 
-	return &tags, nil
+	return tags, nil
 }
 
-func (this Database) TagsForTags(tagNames []string) (*[]Tag, error) {
+func (this Database) TagsForTags(tagNames []string) ([]Tag, error) {
 	sql := `SELECT id, name
             FROM tag
             WHERE id IN (
 		}
 	}
 
-	return &tags, nil
+	return tags, nil
 }
 
 func (this Database) AddTag(name string) (*Tag, error) {
 	return &File{uint(id), path, fingerprint}, nil
 }
 
-func (this Database) FilesWithTags(tagNames []string) (*[]File, error) {
+func (this Database) FilesWithTags(tagNames []string) ([]File, error) {
 	sql := `SELECT id, path, fingerprint
             FROM file
             WHERE id IN (
 		files = append(files, File{fileId, path, fingerprint})
 	}
 
-	return &files, nil
+	return files, nil
 }
 
 func (this Database) UpdateFileFingerprint(fileId uint, fingerprint string) error {
 	return nil
 }
 
-func (this Database) FileTags() (*[]FileTag, error) {
+func (this Database) FileTags() ([]FileTag, error) {
 	sql := `SELECT id, file_id, tag_id
 	        FROM file_tag`
 
 		fileTags = append(fileTags, FileTag{fileTagId, fileId, tagId})
 	}
 
-	return &fileTags, nil
+	return fileTags, nil
 }
 
 func (this Database) FileTagByFileIdAndTagId(fileId uint, tagId uint) (*FileTag, error) {
 	return &FileTag{fileTagId, fileId, tagId}, nil
 }
 
-func (this Database) FileTagsByTagId(tagId uint) (*[]FileTag, error) {
+func (this Database) FileTagsByTagId(tagId uint) ([]FileTag, error) {
 	sql := `SELECT id, file_id
 	        FROM file_tag
 	        WHERE tag_id = ?`
 		fileTags = append(fileTags, FileTag{fileTagId, fileId, tagId})
 	}
 
-	return &fileTags, nil
+	return fileTags, nil
 }
 
 func (this Database) AnyFileTagsForFile(fileId uint) (bool, error) {
 	tags, error := db.Tags()
 	if error != nil { log.Fatal("Could not retrieve tags: %v", error) }
 
-	channel := make(chan fuse.DirEntry, len(*tags))
-	for _, tag := range *tags {
+	channel := make(chan fuse.DirEntry, len(tags))
+	for _, tag := range tags {
 		channel <- fuse.DirEntry{Name: tag.Name, Mode: fuse.S_IFDIR}
 	}
 	close(channel)
 	files, error := db.FilesWithTags(tags)
 	if error != nil { log.Fatalf("Could not retrieve tagged files: %v", error) }
 
-	channel := make(chan fuse.DirEntry, len(*files)+len(*furtherTags))
+	channel := make(chan fuse.DirEntry, len(files) + len(furtherTags))
 	defer close(channel)
 
-	for _, tag := range *furtherTags {
+	for _, tag := range furtherTags {
 		channel <- fuse.DirEntry{Name: tag.Name, Mode: fuse.S_IFDIR | 0755}
 	}
 
-	for _, file := range *files {
+	for _, file := range files {
         linkName := this.getLinkName(file)
 		channel <- fuse.DirEntry{Name: linkName, Mode: fuse.S_IFLNK}
 	}