Performance tweak
This commit is contained in:
parent
ddd87c12c8
commit
14dd42bad0
|
@ -11,13 +11,14 @@ export default class Highlighter {
|
|||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
init = annotations => {
|
||||
// TODO - there are several performance optimzations that are not yet ported
|
||||
// across from Recogito
|
||||
annotations
|
||||
// Discard all annotations without a TextPositionSelector
|
||||
.filter(annotation => annotation.selector('TextPositionSelector'))
|
||||
.forEach(annotation => this._addAnnotation(annotation));
|
||||
init = annotations => {
|
||||
// Discard all annotations without a TextPositionSelector
|
||||
const highlights = annotations.filter(a => a.selector('TextPositionSelector'));
|
||||
|
||||
// Sorting bottom to top significantly speeds things up,
|
||||
// because walkTextNodes will have a lot less to walk
|
||||
highlights.sort((a, b) => b.start - a.start);
|
||||
highlights.forEach(this._addAnnotation);
|
||||
}
|
||||
|
||||
_addAnnotation = annotation => {
|
||||
|
|
Loading…
Reference in New Issue