Closed
      
        Bug 1819269
      
      
        Opened 2 years ago
          Closed 2 years ago
      
        
    
  
disableEmptyLines could be faster  
    Categories
(DevTools :: Debugger, task)
        DevTools
          
        
        
      
        
    
        Debugger
          
        
        
      
        
    Tracking
(firefox112 fixed)
        RESOLVED
        FIXED
        
    
  
        
            112 Branch
        
    
  
| Tracking | Status | |
|---|---|---|
| firefox112 | --- | fixed | 
People
(Reporter: nchevobbe, Assigned: nchevobbe)
Details
Attachments
(1 file)
The function was showing up in a profile (not in big ways, but looks like it could be improved)
disableEmptyLines() {
  const { breakableLines, selectedSource, editor } = this.props;
  editor.codeMirror.operation(() => {
    editor.codeMirror.eachLine(lineHandle => {
      const line = fromEditorLine(
        selectedSource.id,
        editor.codeMirror.getLineNumber(lineHandle)
      );
      if (breakableLines.has(line)) {
        editor.codeMirror.removeLineClass(
          lineHandle,
          "wrapClass",
          "empty-line"
        );
      } else {
        editor.codeMirror.addLineClass(lineHandle, "wrapClass", "empty-line");
      }
    });
  });
}
2 immediate things are visible:
- fromEditorLineis checking if the source is wasm. And so here we check it for every line, while this information is unique per file
export function fromEditorLine(sourceId, line) {
  if (isWasm(sourceId)) {
    return lineToWasmOffset(sourceId, line) || 0;
  }
  return line + 1;
}
- Using codeMirror.eachLinemeans that we need to callcodeMirror.getLineNumber, for each line. SincecodeMirror.(add|remove)LineClasscan take a line index instead of alineHandle, we could have a simple for loop instead.
| Assignee | ||
| Comment 1•2 years ago
           | ||
- Replace codeMirror.eachLinewith a simple for loop
- Change fromEditorLinesignature so it takes a new parameter indicating
 if the source is wasm. This allows us to only compute this information once
 per file, and not for each line of a file.
Depends on D171186
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/52980b1f16ff
[devtools] Make disableEmptyLines faster. r=jdescottes
| Comment 3•2 years ago
           | ||
Backed out for causing Bug 1819531.
Backout link: https://hg.mozilla.org/integration/autoland/rev/6833a092ebd6bea1be81a71cb87a8d55b917e804
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7edfdbd5daf0
[devtools] Make disableEmptyLines faster. r=jdescottes
| Comment 5•2 years ago
           | ||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
          status-firefox112:
          --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
          You need to log in
          before you can comment on or make changes to this bug.
        
Description
•