chatview: major efficiency issues in updateTimestamps
updateTimestamps()
is affected by several design issues with a large drawbacks on performances:
- This function goes through all timestamp entries and is called by
addOrUpdateMessage()
. This means that this function is called each and every time a message is displayed ! This is basically O(n²) algorithm. For instance, displaying 50 messages triggers 1275 timestamp updates. - This function handles both text and position/style updates. The is probably done in order to simulate some kind of responsive behaviour. This should be done by CSS, not JS.