appscript นี้ทำงานเร็วขึ้น/เขียนใหม่เพื่อให้ทำงานเร็วขึ้นเมื่อฉันมี 200 แถวได้หรือไม่

 function colorFirstCell() {

 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheetByName('courseX');
 var lastRow = sheet.getLastRow();
 var lastColumn = sheet.getLastColumn();
 var columnFirstCells = 1; // column of cell to be colored
 var dataRange = sheet.getRange(1,1, lastRow, lastColumn + 1).getValues(); 

for(var i = 0; i < lastRow; i++) 
  {   
  for(var j = 0; j < lastColumn; j++) { 
      if(dataRange[i][j] != '' && dataRange[i][j+1] == '') { // cell not empty and cell to the right is empty
         var backgroundColor = sheet.getRange(i + 1, j + 1).getBackground(); // get color
         sheet.getRange(i + 1, columnFirstCells).setBackground(backgroundColor); // set color 
         of first col cell
          } 
       } 
     } 
  } 
function colorFirstCell2() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('courseX');
  var range = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn());
  var backgrounds = range.getBackgrounds();
  var colors = range.getDisplayValues().map((r, i) => {
    for (var j = r.length - 1; j >= 0; j--) {
      if (r[j] != "") {
        return [backgrounds[i][j]];
      }
    }
    return [null];
  });
  sheet.getRange(1, 1, colors.length).setBackgrounds(colors);
}