From b97d8979c72e5397267e9b77bfb873c551dc176c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 10 Feb 2021 13:18:23 +0100 Subject: [PATCH] Remove nested for loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/messages/TextualBody.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index e3cd9d8f51..ea7aebdb69 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -113,16 +113,12 @@ export default class TextualBody extends React.Component { // Highlight code const codes = ReactDOM.findDOMNode(this).getElementsByTagName("code"); if (codes.length > 0) { - for (let i = 0; i < codes.length; i++) { - // Do this asynchronously: parsing code takes time and we don't - // need to block the DOM update on it. - setTimeout(() => { - if (this._unmounted) return; - for (let i = 0; i < pres.length; i++) { - this._highlightCode(codes[i]); - } - }, 10); - } + setTimeout(() => { + if (this._unmounted) return; + for (let i = 0; i < codes.length; i++) { + this._highlightCode(codes[i]); + } + }, 10); } } }