<commit_before>package store

import (
	"encoding/json"
	"github.com/shorrockin/noted/log"
)

type Note struct {
	Id      uint64 `json:"id"`
	Content string `json:"content"`
}

func (note Note) String() string {
	bytes, error := json.Marshal(note)
	if error != nil {
		log.Warn("encountered error marshelling note: %v", error)
		return ""
	}
	return string(bytes)
}

func (note *Note) FromJson(bytes []byte) (err error) {
	err = json.Unmarshal(bytes, note)
	return
}

// Notes declaration with allows for the marshelling of a collection of
// notes.
type NoteCollection []Note

func (notes NoteCollection) String() string {
	bytes, error := json.Marshal(notes)
	if error != nil {
		log.Warn("encountered error marshelling notes collection: %v", error)
		return ""
	}
	return string(bytes)
}

// Note is a collection of all the notes we're currently managing.
var Notes NoteCollection

// CreateNote creates a note with the specified string as a note
func CreateNote(content string) (note Note) {
	note = Note{NextId(), content}
	Notes = append(Notes, note)
	return
}

// RemoveNote removes the specified note from the system using the
// id to find it.
func RemoveNote(id uint64) {
	for index, note := range Notes {
		if note.Id == id {
			Notes = append(Notes[:index], Notes[index+1:]...)
			return
		}
	}
}
<commit_msg>converted String() functions on objects to use pointers. presumably better practice since you don't have to copy on call?<commit_after>package store

import (
	"encoding/json"
	"github.com/shorrockin/noted/log"
)

type Note struct {
	Id      uint64 `json:"id"`
	Content string `json:"content"`
}

func (note *Note) String() string {
	bytes, error := json.Marshal(note)
	if error != nil {
		log.Warn("encountered error marshelling note: %v", error)
		return ""
	}
	return string(bytes)
}

func (note *Note) FromJson(bytes []byte) (err error) {
	err = json.Unmarshal(bytes, note)
	return
}

// Notes declaration with allows for the marshelling of a collection of
// notes.
type NoteCollection []Note

func (notes *NoteCollection) String() string {
	bytes, error := json.Marshal(notes)
	if error != nil {
		log.Warn("encountered error marshelling notes collection: %v", error)
		return ""
	}
	return string(bytes)
}

// Note is a collection of all the notes we're currently managing.
var Notes NoteCollection

// CreateNote creates a note with the specified string as a note
func CreateNote(content string) (note Note) {
	note = Note{NextId(), content}
	Notes = append(Notes, note)
	return
}

// RemoveNote removes the specified note from the system using the
// id to find it.
func RemoveNote(id uint64) {
	for index, note := range Notes {
		if note.Id == id {
			Notes = append(Notes[:index], Notes[index+1:]...)
			return
		}
	}
}

{'fraction_non_alphanumeric': 0.11882267441860465, 'fraction_numerical': 0.003633720930232558, 'mean_word_length': 3.9693140794223827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4478677', 'n_tokens_mistral': 906, 'n_tokens_neox': 867, 'n_words': 312}