cclaerhout / xen_BBM_v2

Version 2 of the BbCodes and Buttons Manager (BBM) for XenForo (working with TinyMCE 4)
6 stars 1 forks source link

BBM_Helper_Buttons::_detectPhrases #25

Closed Xon closed 8 years ago

Xon commented 9 years ago

When auditing on how to reduce some extra database queries, I noticed this _detectPhrases() could be improved.

It spins in a loop collecting XenForo_Phrase objects for each button, and immediately casting to a string. This causes a database query straight away.

A simple object wrapper with a _toString() method could defer this until all the phrases are resolved at once when the output from bakeQuattroParams/bakeRedactorParams is serialized into a string.

I'll submit a pull-request for this in a few days.

cclaerhout commented 9 years ago

Ok, thanks

Xon commented 9 years ago

I've implemented this; https://github.com/xon/xen_BBM_v2/tree/detectPhrases but I need to finish testing.

It doesn't come up normally due to the use of 'global' phrases. This change would allow those phrases to be removed from the global pool.

cclaerhout commented 8 years ago

Hello, I can't find back what I've just written in your commit. What I wrote didn't make sense, did you try to check what you coded was working ?

Xon commented 8 years ago

I tested with single phrase per item, but not when there are two phrases in the same bit of text.

cclaerhout commented 8 years ago

Ok thanks, I didn't know the magic function string was deferring its elements even when it was not in the view.

cclaerhout commented 8 years ago

I've just tried... and it works great. Thanks again for the code and the information :)

cclaerhout commented 8 years ago

Everything has been updated :) :+1: