File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -38,28 +38,33 @@ export class TfIdfSearchIndex implements ISearchIndex {
3838 /**
3939 * @inheritDocs
4040 */
41- indexDocument ( token : string , uid : string , document : Object ) : void {
41+ indexDocument ( token : string , uid : string , doc : Object ) : void {
4242 this . _tokenToIdfCache = { } ; // New index invalidates previous IDF caches
4343
44- if ( typeof this . _tokenMap [ token ] !== 'object' ) {
45- this . _tokenMap [ token ] = {
44+ var tokenMap = this . _tokenMap ;
45+ var tokenDatum ;
46+
47+ if ( ! tokenMap . hasOwnProperty ( token ) ) {
48+ tokenMap [ token ] = tokenDatum = {
4649 $numDocumentOccurrences : 0 ,
4750 $totalNumOccurrences : 1 ,
4851 $uidMap : { } ,
4952 } ;
5053 } else {
51- this . _tokenMap [ token ] . $totalNumOccurrences ++ ;
54+ tokenDatum = tokenMap [ token ] ;
55+ tokenDatum . $totalNumOccurrences ++ ;
5256 }
5357
54- if ( ! this . _tokenMap [ token ] . $uidMap [ uid ] ) {
55- this . _tokenMap [ token ] . $numDocumentOccurrences ++ ;
58+ var uidMap = tokenDatum . $uidMap ;
5659
57- this . _tokenMap [ token ] . $uidMap [ uid ] = {
58- $document : document ,
60+ if ( ! uidMap . hasOwnProperty ( uid ) ) {
61+ tokenDatum . $numDocumentOccurrences ++ ;
62+ uidMap [ uid ] = {
63+ $document : doc ,
5964 $numTokenOccurrences : 1
6065 } ;
6166 } else {
62- this . _tokenMap [ token ] . $ uidMap[ uid ] . $numTokenOccurrences ++ ;
67+ uidMap [ uid ] . $numTokenOccurrences ++ ;
6368 }
6469 }
6570
You can’t perform that action at this time.
0 commit comments