Avoid unnecessary database reads

Use the cached function isInDatabase rather than readFromDatabase to
 avoid unnecessary read operations on the database.

 Currently, readFromDatabase is usually called only once during instance
 livetime. But after I455b41c8b8d918f4c34f6c115194d227a8394e0a has bben
 merged chances are that it's called twice.

Change-Id: I6434195ad1d323a578a8fdca1b4555e11ab30a15
This commit is contained in:
physikerwelt (Moritz Schubotz) 2014-09-05 21:55:54 -04:00 committed by Physikerwelt
parent 8841fd70b4
commit 4459c5c452
3 changed files with 5 additions and 6 deletions

View File

@ -182,8 +182,7 @@ class MathLaTeXML extends MathMathML {
$renderer = new MathMathML( $this->getTex() );
$renderer->setMathml( $this->getMathml() );
$renderer->setMode( MW_MATH_LATEXML );
$renderer->setPurge( true );
$res = $renderer->render();
$res = $renderer->render( true );
if ( $res == true ) {
$this->svg = $renderer->getSvg();
} else {

View File

@ -104,7 +104,7 @@ class MathMathML extends MathRenderer {
wfDebugLog( "Math", "Rerendering was requested." );
return true;
} else {
$dbres = $this->readFromDatabase();
$dbres = $this->isInDatabase();
if ( $dbres ) {
if ( $this->isValidMathML( $this->getMathml() ) ) {
wfDebugLog( "Math", "Valid MathML entry found in database." );

View File

@ -387,7 +387,7 @@ class MathTexvc extends MathRenderer {
global $wgMathCheckFiles;
wfProfileIn( __METHOD__ );
if ( $this->readFromDatabase() ) {
if ( $this->isInDatabase() ) {
if ( !$wgMathCheckFiles ) {
// Short-circuit the file existence & migration checks
wfProfileOut( __METHOD__ );
@ -413,8 +413,8 @@ class MathTexvc extends MathRenderer {
return $backend->getFileContents( array( 'src' => $this->getHashPath() . "/" . $this->getHash() . '.png' ) );
}
public function readFromDatabase() {
$return = parent::readFromDatabase();
public function isInDatabase() {
$return = parent::isInDatabase();
if ( $this->hash && $return ) {
return true;
} else {