Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252
Modified Files:
serendipity_functions.inc.php
Log Message:
Seems like I'm the only one reading George's book? ;-)
"Implementing this simple change reduces the number of date() calls from 240
to 38, improves the speed of serendipity_plugin_api::generate_plugins() by
more than 20%, and reduces the overall execution time of the index page by
10%."
Nowadays it shouldn't inflict a 20% performance gain for the
serendipity_plugin_api call, but still it's now performing better. Hope I
didn't include a followup-error to reverse the effect.
Apart from that I'm sure nobody actually reads my essay here, so I'll just
quit swamping the CVS Log. :-)
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -d -r1.269 -r1.270
--- serendipity_functions.inc.php 19 May 2004 09:27:30 -0000 1.269
+++ serendipity_functions.inc.php 19 May 2004 16:07:11 -0000 1.270
@@ -376,7 +376,7 @@
$minmax = array(
'0' => array(
'min' => mktime(0, 0, 0, 1, 1, date('Y')-1),
- 'max' => mktime(0, 0, 0, 1, 1, date('Y'+1))
+ 'max' => mktime(0, 0, 0, 1, 1, date('Y')+1)
)
);
}
@@ -438,28 +438,31 @@
<tr>
<?php
-for ( $i = 1; $i <= 7; $i++ ) {
- $date = mktime(0,0,0,3,$bow+$i-1,2004);
+ for ($i = 1; $i <= 7; $i++) {
+ $date = mktime(0,0,0,3,$bow+$i-1,2004);
?>
<td class="serendipity_weekDayName" align="center"><?php echo substr(strftime("%a", $date),0,2); ?></td>
<?php
-}
+ }
?>
</tr>
<?php
// Print the calendar
- $currDay = 1;
- for ($x=0; $x<6; $x++) {
+ $currDay = 1;
+ $today_day = date('j');
+ $today_month = date('m');
+ $today_year = date('Y');
+ for ($x = 0; $x < 6; $x++) {
// Break out if we are out of days
- if ($currDay>$nrOfDays) {
+ if ($currDay > $nrOfDays) {
break;
}
?>
<tr class="serendipity_calendar">
<?php
// Prepare row
- for ($y=0; $y<7; $y++) {
+ for ($y = 0; $y < 7; $y++) {
// Be able to print borders nicely
if ($x == 4 && $y == 6) {
$cellProp = 'LastInLastRow';
@@ -474,19 +477,16 @@
}
// Start printing
- if ( ($x > 0 || $y >= $firstDayWeekDay)
+ if (($x > 0 || $y >= $firstDayWeekDay)
&& $currDay <= $nrOfDays) {
if (isset($activeDays[$currDay]) && $activeDays[$currDay] > 1) {
$cellProp .= 'Active';
}
- // Print day
- $link = serendipity_archiveDateUrl(date('Ymd', mktime(0,0,0, $month, $currDay, $year))) . $base_query;
-
- if (date('m') == $month
- && date('Y') == $year
- && $currDay == date('j')) {
+ if ($today_year == $year
+ && $today_month == $month
+ && $today_day == $currDay) {
$att_start = '<i>';
$att_end = '</i>';
} else {
@@ -495,7 +495,7 @@
}
if (isset($activeDays[$currDay]) && $activeDays[$currDay] > 1) {
- $lnk_start = '<a href="' . $link . '">'; //?month=".sprintf("%02d",$month)."&year=$year'>");
+ $lnk_start = '<a href="' . serendipity_archiveDateUrl(sprintf('%4d%02d%02d', $year, $month, $currDay)) . $base_query . '">'; //?month=".sprintf("%02d",$month)."&year=$year'>");
$lnk_end = '</a>';
} else {
$lnk_start = '';
|