OP here, thanks for the replies. By "global" I meant to somehow disable all the slow sanity checks in Imager.pm. Methods like setpixel and getpixel are likely to be called a lot inside loops. Disabling the call to _valid_image on each pixel seems pretty safe so far and is a big gain. Since _valid_image is called in almost every method in Imager.pm they can all be fixed on line 658:
The second hack that skips the call to _color is crude because it disables dwim on the color attribute of setpixel (color=>'blue') and requires it be supplied with an Imager::Color object (color=>Imager::Color->new('blue')). Doing that right would require more work but it hasn't broken my code so far while patching a live copy of Imager.pm. Probably because it was noticed long ago that dwim colors are to be avoided because setpixel is 2-3x faster when using color objects with rgb arrays like Imager::Color->new([255,0,0]).sub _valid_image { return 1;
In reply to Re^2: Double the speed of Imager->setpixel
by Anonymous Monk
in thread Double the speed of Imager->setpixel
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |