Building GEOS on CentOS

It should be simple, but I ran into a number of errors.

First I got stuck on libtool: line 990: g++: command not found. It turns out I needed to install g++ using:

yum install gcc-c++

Then I got stuck on this one:

platform.h:110:2: error: #error "Can not compile without isnan function or macro
"Coordinate.inl:38: error: ‘ISNAN’ was not declared in this scope

The author of this page faced the problem, but the real insight came from this bug report on an unrelated project:

In these versions of g++ isnan is defined as a macro in unless is included, in which case std::isnan() is defined instead.

And so I tried replacing #include <math.h> with #include <cmath> in include/geos/platform.h. Amazingly, that worked.

Testing apply_filters() times

Testing how long it takes to assign a variable versus assigning through WordPress’ apply_filters(). Filters are core to WordPress, but I haven’t yet looked at the total number of apply_filters() calls used throughout the code. The answer to this question is that calling a non-existing filter before assignment is about 21 times more costly than […] » about 300 words

Testing file include times for a file that may or may not exist

Question: Should you check for a file before attempting to include it, or just suppress errors? Calling file_exists requires stating it twice if the file does exist, so that could take longer. Answer: the file_exists pattern is more than five times faster than the @include pattern for a file that doesn’t exist, and not substantially […] » about 300 words

On wp_enqueue_scripts and admin_enqueue_scripts

An argument has erupted over the WordPress actions wp_enqueue_scripts and admin_enqueue_scripts vs. init. One of the points was about specificity, and how wp_enqueue_scripts and admin_enqueue_scripts can reduce ambiguity. I didn’t realize I had strong opinions on it until the issue was pressed, but it turns out I think wp_enqueue_scripts and admin_enqueue_scripts are unnecessary and unfortunate additions […] » about 300 words

Confirming that object references in arrays are preserved while cloning the arrays

A short test to confirm references are preserved in cloned arrays. The result is: Now let’s mess with one piece of that to check if the object was passed by reference or got cloned: Confirmed, the object is passed by reference, even though the array that contained it was cloned: » about 300 words


I have Matthew Batchelder to thank for introducing me to PHPQuery. I haven’t used it yet, but someday I’ll have need to select text elements from HTML using the PHP5 PEAR module. From the description “server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on jQuery JavaScript Library.”

Why PHP’s RegEx Is Slow, And What You Can Do About It (if you happen to be a committer on the PHP project)

Regular Expression Matching Can Be Simple And Fast, by Russ Cox:

Perl [and PHP and others] could not now remove backreference support, of course, but they could employ much faster algorithms when presented with regular expressions that don’t have backreferences.

How much faster? About a million times (no, I do not exaggerate).

I use a lot of regular expressions, and relatively few of them use backreferences. It’d be worth optimizing.

Lessons Learned: Why It’s Better Not To Use Parentheses When They’re Optional

There it is in the PHP manual for return():

Note: since return() is a language construct and not a function, the parentheses surrounding its arguments are not required. It is common to leave them out, and you actually should do so as PHP has less work to do in this case.

I knew the parentheses were optional, but I’ve been merrily using them all along. And I probably would have continued doing so until I saw the second note attached to the docs:

Note: You should never use parentheses around your return variable when returning by reference, as this will not work. You can only return variables by reference, not the result of a statement. If you use return ($a); then you’re not returning a variable, but the result of the expression ($a) (which is, of course, the value of $a).