File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
packages/apollo-collaboration-server/src/checks Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -108,12 +108,26 @@ export class ChecksService {
108108 if ( ! c ) {
109109 throw new Error ( `Check "${ check . name } " not registered` )
110110 }
111- const result = await c . checkFeature (
112- flatDoc ,
113- ( start : number , end : number ) => {
111+ // If the feature is small enough, just fetch its sequence once and
112+ // substring that to avoid slow disk reads
113+ let featureSequence : string | undefined
114+ if ( doc . max - doc . min <= 1_000_000 ) {
115+ featureSequence = await this . getSequence ( {
116+ start : doc . min ,
117+ end : doc . max ,
118+ featureDoc : doc ,
119+ } )
120+ }
121+ // eslint-disable-next-line unicorn/consistent-function-scoping
122+ const getSequence = ( start : number , end : number ) => {
123+ if ( ! featureSequence || start < doc . min || end > doc . max ) {
114124 return this . getSequence ( { start, end, featureDoc : doc } )
115- } ,
116- )
125+ }
126+ return Promise . resolve (
127+ featureSequence . slice ( start - doc . min , end - doc . min ) ,
128+ )
129+ }
130+ const result = await c . checkFeature ( flatDoc , getSequence )
117131 if ( result . length > 0 ) {
118132 await this . checkResultModel . insertMany ( result )
119133 }
You can’t perform that action at this time.
0 commit comments