r77009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77008‎ | r77009 | r77010 >
Date:06:49, 19 November 2010
Author:tstarling
Status:ok
Tags:
Comment:
* Some tweaks to wfMemoryLimit() to make it a bit faster.
* Fixed inappropriate use of empty(), added "break missing" comments as in zend_atol()
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3451,8 +3451,8 @@
34523452 function wfMemoryLimit() {
34533453 global $wgMemoryLimit;
34543454 $memlimit = wfShorthandToInteger( ini_get( 'memory_limit' ) );
3455 - $conflimit = wfShorthandToInteger( $wgMemoryLimit );
34563455 if( $memlimit != -1 ) {
 3456+ $conflimit = wfShorthandToInteger( $wgMemoryLimit );
34573457 if( $conflimit == -1 ) {
34583458 wfDebug( "Removing PHP's memory limit\n" );
34593459 wfSuppressWarnings();
@@ -3477,17 +3477,22 @@
34783478 */
34793479 function wfShorthandToInteger( $string = '' ) {
34803480 $string = trim( $string );
3481 - if( empty( $string ) ) {
 3481+ if( $string === '' ) {
34823482 return -1;
34833483 }
3484 - $last = strtolower( $string[strlen( $string ) - 1] );
 3484+ $last = $string[strlen( $string ) - 1];
34853485 $val = intval( $string );
34863486 switch( $last ) {
34873487 case 'g':
 3488+ case 'G':
34883489 $val *= 1024;
 3490+ // break intentionally missing
34893491 case 'm':
 3492+ case 'M':
34903493 $val *= 1024;
 3494+ // break intentionally missing
34913495 case 'k':
 3496+ case 'K':
34923497 $val *= 1024;
34933498 }
34943499

Status & tagging log