mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
Remove O(N) cell by msg-id lookup
This commit is contained in:
parent
ff39989b8b
commit
bad85fb879
@ -105,6 +105,7 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
};
|
||||
|
||||
CodeCell.msg_cells = {};
|
||||
|
||||
CodeCell.prototype = new IPython.Cell();
|
||||
|
||||
@ -317,7 +318,12 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
var callbacks = this.get_callbacks();
|
||||
|
||||
var old_msg_id = this.last_msg_id;
|
||||
this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
|
||||
if (old_msg_id) {
|
||||
delete CodeCell.msg_cells[old_msg_id];
|
||||
}
|
||||
CodeCell.msg_cells[this.last_msg_id] = this;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -308,12 +308,8 @@ var IPython = (function (IPython) {
|
||||
* @return {Cell} Cell or null if no cell was found.
|
||||
*/
|
||||
Notebook.prototype.get_msg_cell = function (msg_id) {
|
||||
var cells = this.get_cells();
|
||||
for (var cell_index in cells) {
|
||||
if (cells[cell_index].last_msg_id == msg_id) {
|
||||
var cell = this.get_cell(cell_index)
|
||||
return cell;
|
||||
}
|
||||
if (IPython.CodeCell.msg_cells[msg_id] !== undefined) {
|
||||
return IPython.CodeCell.msg_cells[msg_id];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user