Skip to content

Commit f1087f8

Browse files
committed
Return array slice for the METS ocr file names
1 parent 7503e93 commit f1087f8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/handler/indexer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ func getOcrFilesFromAnnotationList(annotations []model.ResourceAnnotation) []str
185185

186186
// getMetsOcrFileNames creates the array of file names from the METS file.
187187
func getMetsOcrFileNames(metsReader io.Reader) []string {
188-
var fileNames = make([]string, 50)
188+
var fileNames = make([]string, 100)
189189
parser := xml.NewDecoder(metsReader)
190190
ocrFileElement := false
191-
altoCounter := 0
191+
ocrCounter := 0
192192
for {
193193
token, err := parser.Token()
194194
if err != nil {
@@ -208,13 +208,13 @@ func getMetsOcrFileNames(metsReader io.Reader) []string {
208208
for i := 0; i < len(t.Attr); i++ {
209209
if t.Attr[i].Name.Local == "href" {
210210
// Allocate more capacity.
211-
if altoCounter == cap(fileNames) {
211+
if ocrCounter == cap(fileNames) {
212212
newFileNames := make([]string, 2*cap(fileNames))
213213
copy(newFileNames, fileNames)
214214
fileNames = newFileNames
215215
}
216-
fileNames[altoCounter] = t.Attr[i].Value
217-
altoCounter++
216+
fileNames[ocrCounter] = t.Attr[i].Value
217+
ocrCounter++
218218
}
219219
}
220220
}
@@ -227,7 +227,7 @@ func getMetsOcrFileNames(metsReader io.Reader) []string {
227227
}
228228
}
229229

230-
return fileNames
230+
return fileNames[:ocrCounter]
231231

232232
}
233233

0 commit comments

Comments
 (0)