mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
some optimisation and code cleaning
optimisation are not obvious, but order and time of attribute creation in javascript have impact for VMs apparently (Google IO talk on V8)
This commit is contained in:
parent
048ccde41b
commit
33dd73eea4
@ -39,18 +39,28 @@ var IPython = (function (IPython) {
|
||||
this.placeholder = options.placeholder || '';
|
||||
this.read_only = options.cm_config.readOnly;
|
||||
this.selected = false;
|
||||
this.element = null;
|
||||
this.metadata = {};
|
||||
// load this from metadata later ?
|
||||
this.user_highlight = 'auto';
|
||||
this.cm_config = options.cm_config;
|
||||
this.cell_id = utils.uuid();
|
||||
this._options = options;
|
||||
|
||||
// For JS VM engines optimisation, attributes should be all set (even
|
||||
// to null) in the constructor, and if possible, if different subclass
|
||||
// have new attributes with same name, they should be created in the
|
||||
// same order. Easiest is to create and set to null in parent class.
|
||||
|
||||
this.element = null;
|
||||
this.cell_type = null;
|
||||
this.code_mirror = null;
|
||||
|
||||
|
||||
this.create_element();
|
||||
if (this.element !== null) {
|
||||
this.element.data("cell", this);
|
||||
this.bind_events();
|
||||
}
|
||||
this.cell_id = utils.uuid();
|
||||
this._options = options;
|
||||
};
|
||||
|
||||
Cell.options_default = {
|
||||
@ -309,7 +319,6 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
if (mode.search('magic_') != 0) {
|
||||
this.code_mirror.setOption('mode', mode);
|
||||
console.log('from',current_mode,'to',mode)
|
||||
CodeMirror.autoLoadMode(this.code_mirror, mode);
|
||||
return;
|
||||
}
|
||||
@ -336,7 +345,6 @@ var IPython = (function (IPython) {
|
||||
);
|
||||
});
|
||||
this.code_mirror.setOption('mode', mmode);
|
||||
console.log('from',current_mode,'to', mmode)
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -352,7 +360,6 @@ var IPython = (function (IPython) {
|
||||
return
|
||||
}
|
||||
this.code_mirror.setOption('mode', default_mode);
|
||||
console.log('from',current_mode,'to', default_mode)
|
||||
};
|
||||
|
||||
IPython.Cell = Cell;
|
||||
|
@ -62,11 +62,17 @@ var IPython = (function (IPython) {
|
||||
*/
|
||||
var CodeCell = function (kernel, options) {
|
||||
this.kernel = kernel || null;
|
||||
this.code_mirror = null;
|
||||
this.input_prompt_number = null;
|
||||
this.collapsed = false;
|
||||
this.cell_type = "code";
|
||||
|
||||
// create all attributed in constructor function
|
||||
// even if null for V8 VM optimisation
|
||||
this.input_prompt_number = null;
|
||||
this.celltoolbar = null;
|
||||
this.output_area = null;
|
||||
this.last_msg_id = null;
|
||||
this.completer = null;
|
||||
|
||||
|
||||
var cm_overwrite_options = {
|
||||
onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
|
||||
@ -129,13 +135,7 @@ var IPython = (function (IPython) {
|
||||
cell.append(input).append(output);
|
||||
this.element = cell;
|
||||
this.output_area = new IPython.OutputArea(output, true);
|
||||
|
||||
// construct a completer only if class exist
|
||||
// otherwise no print view
|
||||
if (IPython.Completer !== undefined)
|
||||
{
|
||||
this.completer = new IPython.Completer(this);
|
||||
}
|
||||
this.completer = new IPython.Completer(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user