mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-05 17:40:26 +00:00
Make some functions unexported
This commit is contained in:
parent
cd18a99bc0
commit
fbcbd0e445
@ -33,20 +33,20 @@ func fetchText(h *Hypha) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// BacklinkIndexOperation is an operation for the backlink index. This operation is executed async-safe.
|
||||
type BacklinkIndexOperation interface {
|
||||
Apply()
|
||||
// backlinkIndexOperation is an operation for the backlink index. This operation is executed async-safe.
|
||||
type backlinkIndexOperation interface {
|
||||
apply()
|
||||
}
|
||||
|
||||
// BacklinkIndexEdit contains data for backlink index update after a hypha edit
|
||||
type BacklinkIndexEdit struct {
|
||||
// backlinkIndexEdit contains data for backlink index update after a hypha edit
|
||||
type backlinkIndexEdit struct {
|
||||
Name string
|
||||
OldLinks []string
|
||||
NewLinks []string
|
||||
}
|
||||
|
||||
// Apply changes backlink index respective to the operation data
|
||||
func (op BacklinkIndexEdit) Apply() {
|
||||
func (op backlinkIndexEdit) apply() {
|
||||
oldLinks := toLinkSet(op.OldLinks)
|
||||
newLinks := toLinkSet(op.NewLinks)
|
||||
for link := range oldLinks {
|
||||
@ -64,14 +64,14 @@ func (op BacklinkIndexEdit) Apply() {
|
||||
}
|
||||
}
|
||||
|
||||
// BacklinkIndexDeletion contains data for backlink index update after a hypha deletion
|
||||
type BacklinkIndexDeletion struct {
|
||||
// backlinkIndexDeletion contains data for backlink index update after a hypha deletion
|
||||
type backlinkIndexDeletion struct {
|
||||
Name string
|
||||
Links []string
|
||||
}
|
||||
|
||||
// Apply changes backlink index respective to the operation data
|
||||
func (op BacklinkIndexDeletion) Apply() {
|
||||
func (op backlinkIndexDeletion) apply() {
|
||||
for _, link := range op.Links {
|
||||
if lSet, exists := backlinkIndex[link]; exists {
|
||||
delete(lSet, op.Name)
|
||||
@ -79,15 +79,15 @@ func (op BacklinkIndexDeletion) Apply() {
|
||||
}
|
||||
}
|
||||
|
||||
// BacklinkIndexRenaming contains data for backlink index update after a hypha renaming
|
||||
type BacklinkIndexRenaming struct {
|
||||
// backlinkIndexRenaming contains data for backlink index update after a hypha renaming
|
||||
type backlinkIndexRenaming struct {
|
||||
OldName string
|
||||
NewName string
|
||||
Links []string
|
||||
}
|
||||
|
||||
// Apply changes backlink index respective to the operation data
|
||||
func (op BacklinkIndexRenaming) Apply() {
|
||||
func (op backlinkIndexRenaming) apply() {
|
||||
for _, link := range op.Links {
|
||||
if lSet, exists := backlinkIndex[link]; exists {
|
||||
delete(lSet, op.OldName)
|
||||
@ -97,7 +97,7 @@ func (op BacklinkIndexRenaming) Apply() {
|
||||
}
|
||||
|
||||
var backlinkIndex = make(map[string]linkSet)
|
||||
var backlinkConveyor = make(chan BacklinkIndexOperation, 64)
|
||||
var backlinkConveyor = make(chan backlinkIndexOperation, 64)
|
||||
|
||||
// I hope, the buffer size is enough -- chekoopa
|
||||
// Do we really need the buffer though? Dunno -- bouncepaw
|
||||
@ -122,7 +122,7 @@ func RunBacklinksConveyor() {
|
||||
// It is supposed to run as a goroutine for all the time. So, don't blame the infinite loop.
|
||||
defer close(backlinkConveyor)
|
||||
for {
|
||||
(<-backlinkConveyor).Apply()
|
||||
(<-backlinkConveyor).apply()
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,19 +138,19 @@ func BacklinksCount(h *Hypha) int {
|
||||
func BacklinksOnEdit(h *Hypha, oldText string) {
|
||||
oldLinks := extractHyphaLinksFromContent(h.Name, oldText)
|
||||
newLinks := extractHyphaLinks(h)
|
||||
backlinkConveyor <- BacklinkIndexEdit{h.Name, oldLinks, newLinks}
|
||||
backlinkConveyor <- backlinkIndexEdit{h.Name, oldLinks, newLinks}
|
||||
}
|
||||
|
||||
// BacklinksOnDelete is a deletion hook for backlinks index
|
||||
func BacklinksOnDelete(h *Hypha, oldText string) {
|
||||
oldLinks := extractHyphaLinksFromContent(h.Name, oldText)
|
||||
backlinkConveyor <- BacklinkIndexDeletion{h.Name, oldLinks}
|
||||
backlinkConveyor <- backlinkIndexDeletion{h.Name, oldLinks}
|
||||
}
|
||||
|
||||
// BacklinksOnRename is a renaming hook for backlinks index
|
||||
func BacklinksOnRename(h *Hypha, oldName string) {
|
||||
actualLinks := extractHyphaLinks(h)
|
||||
backlinkConveyor <- BacklinkIndexRenaming{oldName, h.Name, actualLinks}
|
||||
backlinkConveyor <- backlinkIndexRenaming{oldName, h.Name, actualLinks}
|
||||
}
|
||||
|
||||
// YieldHyphaBacklinks gets backlinks for a desired hypha, sorts and iterates over them
|
||||
|
@ -17,21 +17,23 @@ func ResetCount() {
|
||||
count.Unlock()
|
||||
}
|
||||
|
||||
// IncrementCount increments the value of the hyphae counter. Use when creating new hyphae or loading hyphae from disk.
|
||||
func IncrementCount() {
|
||||
// Count how many hyphae there are.
|
||||
func Count() int {
|
||||
count.Lock()
|
||||
defer count.Unlock()
|
||||
return count.value
|
||||
}
|
||||
|
||||
// incrementCount increments the value of the hyphae counter. Use when creating new hyphae or loading hyphae from disk.
|
||||
func incrementCount() {
|
||||
count.Lock()
|
||||
count.value++
|
||||
count.Unlock()
|
||||
}
|
||||
|
||||
// DecrementCount decrements the value of the hyphae counter. Use when deleting existing hyphae.
|
||||
func DecrementCount() {
|
||||
// decrementCount decrements the value of the hyphae counter. Use when deleting existing hyphae.
|
||||
func decrementCount() {
|
||||
count.Lock()
|
||||
count.value--
|
||||
count.Unlock()
|
||||
}
|
||||
|
||||
// Count how many hyphae there are.
|
||||
func Count() int {
|
||||
return count.value
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ func Index(path string) {
|
||||
for h := range ch {
|
||||
// It's safe to ignore the mutex because there is a single worker right now.
|
||||
if oh := ByName(h.Name); oh.Exists {
|
||||
oh.MergeIn(h)
|
||||
oh.mergeIn(h)
|
||||
} else {
|
||||
h.Insert()
|
||||
h.insert()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,14 +82,14 @@ func storeHypha(h *Hypha) {
|
||||
h.Unlock()
|
||||
}
|
||||
|
||||
// Insert inserts the hypha into the storage. A previous record is used if possible. Count incrementation is done if needed.
|
||||
func (h *Hypha) Insert() (justRecorded bool) {
|
||||
// insert inserts the hypha into the storage. A previous record is used if possible. Count incrementation is done if needed.
|
||||
func (h *Hypha) insert() (justRecorded bool) {
|
||||
hp, recorded := byNames[h.Name]
|
||||
if recorded {
|
||||
hp.MergeIn(h)
|
||||
hp.mergeIn(h)
|
||||
} else {
|
||||
storeHypha(h)
|
||||
IncrementCount()
|
||||
incrementCount()
|
||||
}
|
||||
|
||||
return !recorded
|
||||
@ -98,7 +98,7 @@ func (h *Hypha) Insert() (justRecorded bool) {
|
||||
// InsertIfNew checks whether hypha exists and returns `true` if it didn't and has been created.
|
||||
func (h *Hypha) InsertIfNew() (justRecorded bool) {
|
||||
if !h.Exists {
|
||||
return h.Insert()
|
||||
return h.insert()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -108,7 +108,7 @@ func (h *Hypha) Delete() {
|
||||
byNamesMutex.Lock()
|
||||
h.Lock()
|
||||
delete(byNames, h.Name)
|
||||
DecrementCount()
|
||||
decrementCount()
|
||||
byNamesMutex.Unlock()
|
||||
h.Unlock()
|
||||
}
|
||||
@ -124,8 +124,8 @@ func (h *Hypha) RenameTo(newName string) {
|
||||
h.Unlock()
|
||||
}
|
||||
|
||||
// MergeIn merges in content file paths from a different hypha object. Prints warnings sometimes.
|
||||
func (h *Hypha) MergeIn(oh *Hypha) {
|
||||
// mergeIn merges in content file paths from a different hypha object. Prints warnings sometimes.
|
||||
func (h *Hypha) mergeIn(oh *Hypha) {
|
||||
if h == oh {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user