Improve line wrapping perf

This commit is contained in:
khlieng 2015-02-27 16:58:46 +01:00
parent 2f1e72876b
commit d25311d07f
2 changed files with 8 additions and 1 deletions

View File

@ -36,6 +36,7 @@ var selectedTabStore = Reflux.createStore({
part: function(channels, server) {
if (server === selectedTab.server &&
channels.indexOf(selectedTab.channel) !== -1) {
selectedTab.server = null;
selectedTab.channel = null;
selectedTab.name = null;
this.trigger(selectedTab);

View File

@ -19,10 +19,16 @@ exports.timestamp = function(date) {
exports.wrapMessages = function(messages, width, charWidth, indent = 0) {
for (var j = 0, llen = messages.length; j < llen; j++) {
var message = messages[j];
var lineWidth = (6 + (message.from ? message.from.length + 1 : 0)) * charWidth;
if (lineWidth + message.message.length * charWidth < width) {
message.lines = [message.message];
continue;
}
var words = message.message.split(' ');
var line = '';
var wrapped = [];
var lineWidth = (6 + (message.from ? message.from.length + 1 : 0)) * charWidth;
var wordCount = 0;
var hasWrapped = false;