Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Do not use library method in Position#offset.
Browse files Browse the repository at this point in the history
This is a performance enhancement. Offset is calculated many times in model operations. Getters should be As Fast As Possible thus calling external method that do too much is not desired here.
  • Loading branch information
jodator committed Apr 3, 2020
1 parent abf6d1f commit 75a53ec
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/model/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import TreeWalker from './treewalker';
import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import Text from './text';
import { last } from 'lodash-es';

// To check if component is loaded more than once.
import '@ckeditor/ckeditor5-utils/src/version';
Expand Down Expand Up @@ -141,7 +140,7 @@ export default class Position {
* @type {Number}
*/
get offset() {
return last( this.path );
return this.path[ this.path.length - 1 ];
}

/**
Expand Down

0 comments on commit 75a53ec

Please sign in to comment.