perf(console): reduce memory, 30% drop

This commit is contained in:
surunzi
2019-10-31 11:39:29 +08:00
parent a58075457a
commit 79ec650cae
2 changed files with 5 additions and 4 deletions

View File

@@ -144,7 +144,7 @@ export default class Log {
return this.el.outerHTML
}
text() {
return this.el.textContent
return this._content.textContent
}
_needSrc() {
const { type, args } = this
@@ -287,7 +287,6 @@ export default class Log {
}
if (type !== 'error') msg = recognizeUrl(msg)
this.value = msg
msg = render({ msg, type, icon, id, displayHeader, time, from, group })
if (!this._needSrc() || !Log.lazyEvaluation) {
@@ -295,6 +294,8 @@ export default class Log {
}
this._$el.addClass('eruda-log-container').html(msg)
this._$content = this._$el.find('.eruda-log-content')
this._content = this._$content.get(0)
}
}

View File

@@ -342,9 +342,9 @@ export default class Logger extends Emitter {
if (
!contain(['html', 'group', 'groupCollapsed'], log.type) &&
lastLog.type === log.type &&
lastLog.value === log.value &&
!log.src &&
!log.args
!log.args &&
lastLog.text() === log.text()
) {
lastLog.addCount()
if (log.time) lastLog.updateTime(log.time)