##// END OF EJS Templates
Remove O(N) cell by msg-id lookup
Jonathan Frederic -
Show More
@@ -105,6 +105,7 b' var IPython = (function (IPython) {'
105 }
105 }
106 };
106 };
107
107
108 CodeCell.msg_cells = {};
108
109
109 CodeCell.prototype = new IPython.Cell();
110 CodeCell.prototype = new IPython.Cell();
110
111
@@ -317,7 +318,12 b' var IPython = (function (IPython) {'
317 }
318 }
318 var callbacks = this.get_callbacks();
319 var callbacks = this.get_callbacks();
319
320
321 var old_msg_id = this.last_msg_id;
320 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
322 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
323 if (old_msg_id) {
324 delete CodeCell.msg_cells[old_msg_id];
325 }
326 CodeCell.msg_cells[this.last_msg_id] = this;
321 };
327 };
322
328
323 /**
329 /**
@@ -308,12 +308,8 b' var IPython = (function (IPython) {'
308 * @return {Cell} Cell or null if no cell was found.
308 * @return {Cell} Cell or null if no cell was found.
309 */
309 */
310 Notebook.prototype.get_msg_cell = function (msg_id) {
310 Notebook.prototype.get_msg_cell = function (msg_id) {
311 var cells = this.get_cells();
311 if (IPython.CodeCell.msg_cells[msg_id] !== undefined) {
312 for (var cell_index in cells) {
312 return IPython.CodeCell.msg_cells[msg_id];
313 if (cells[cell_index].last_msg_id == msg_id) {
314 var cell = this.get_cell(cell_index)
315 return cell;
316 }
317 }
313 }
318 return null;
314 return null;
319 };
315 };
General Comments 0
You need to be logged in to leave comments. Login now