Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve the performance of display refresh.

Just setting textContent on a <td> actually implicitly removes the
existing text node and appends a new one; Instead, just mutate the
existing text node.

This is especially painful on Chrome with the "Edit with emacs"
extension, which has a hook that runs whenever the DOM is modified.
  • Loading branch information...
commit fa7b174047a29360b7c78862d30916bb8867b6f0 1 parent fc20993
@nelhage authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 betaweb.js
View
6 betaweb.js
@@ -80,7 +80,7 @@ function initBeta() {
cells = rows[i].cells;
for (j = 0; j < cells.length; j++) {
if (cells[j].nodeName == 'TD')
- BETA.regCells.push(cells[j]);
+ BETA.regCells.push(cells[j].firstChild);
}
}
@@ -129,7 +129,7 @@ function resetBeta(rom) {
var th = document.createElement('th');
var td = document.createElement('td');
th.textContent = toHex(i) + ":";
- td.textContent = '';
+ td.appendChild(document.createTextNode())
tr.appendChild(th);
tr.appendChild(td);
BETA.memTab.appendChild(tr);
@@ -168,7 +168,7 @@ function refreshDisplay() {
for (i = 0; i < 31; i++)
BETA.regCells[i].textContent = toHex(CPU.regs[i]);
for (i = 0; i < MMU.memory.length; i++)
- BETA.memTab.rows[i].cells[1].textContent = toHex(MMU.memory[i]);
+ BETA.memTab.rows[i].cells[1].firstChild.textContent = toHex(MMU.memory[i]);
}
function initTerm() {
Please sign in to comment.
Something went wrong with that request. Please try again.