File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,7 +242,9 @@ export async function POST(
242242 }
243243
244244 const existingNodeIds = existingNodes ?. map ( ( n ) => n . id ) || [ ] ;
245- const missingNodes = node_ids . filter ( ( id ) => ! existingNodeIds . includes ( id ) ) ;
245+ // Bolt Optimization: Pre-compute Set for O(1) lookup instead of O(N) array includes
246+ const existingNodeIdsSet = new Set ( existingNodeIds ) ;
247+ const missingNodes = node_ids . filter ( ( id ) => ! existingNodeIdsSet . has ( id ) ) ;
246248
247249 if ( missingNodes . length > 0 ) {
248250 return NextResponse . json (
Original file line number Diff line number Diff line change @@ -262,7 +262,9 @@ export async function GET(
262262
263263 // Get additional profiles for members not in submissions
264264 const classroomUserIds = classroomMembers . map ( m => m . user_id ) ;
265- const missingUserIds = classroomUserIds . filter ( id => ! submissionUserIds . includes ( id ) ) ;
265+ // Bolt Optimization: Pre-compute Set for O(1) lookup instead of O(N) array includes
266+ const submissionUserIdsSet = new Set ( submissionUserIds ) ;
267+ const missingUserIds = classroomUserIds . filter ( id => ! submissionUserIdsSet . has ( id ) ) ;
266268
267269 let additionalProfiles : any [ ] = [ ] ;
268270 if ( missingUserIds . length > 0 ) {
You can’t perform that action at this time.
0 commit comments