# [PATCH] Small date() optimization

- Thread: https://externals.io/message/27174
- Original archive: https://news-web.php.net/php.internals/27174
- Started by Matt Wilmas on 2006-12-22T05:06:41+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27174 — Matt Wilmas — 2006-12-22T05:06:41+00:00

URL: https://externals.io/message/27174#27174

Hi,

Just a simple patch for 5.2 to save smart_str_appends()'s `strlen()` calls in
 `date_format()`.  It's already done in HEAD.  Seems pretty safe for 5.2.1. :-)

I also noticed that if the format string contains a backslash as the last
character, it is lost (should be printed right?).  So I changed that too and
attached the patch for HEAD.

5.2's patch:
http://realplain.com/php/date_optimization_5_2.diff


Matt

---

## #27180 — Ilia Alshanetsky — 2006-12-22T15:07:10+00:00

URL: https://externals.io/message/27174#27180 · In reply to: #27174

Matt,

The backslash removal is actually intentional. It is designed to  
handle instances such as "\d", in which case the format value is  
printed as a literal "d".




> Hi,
>
> Just a simple patch for 5.2 to save smart_str_appends()'s `strlen()`  
> calls in
> `date_format()`.  It's already done in HEAD.  Seems pretty safe for  
> 5.2.1. :-)
>
> I also noticed that if the format string contains a backslash as  
> the last
> character, it is lost (should be printed right?).  So I changed  
> that too and
> attached the patch for HEAD.
>
> 5.2's patch:
> http://realplain.com/php/date_optimization_5_2.diff
>
>
> Matt
> <date_backslash.diff.txt>
> -- 
> 
> 

Ilia Alshanetsky

---

## #27181 — Matt Wilmas — 2006-12-22T15:20:34+00:00

URL: https://externals.io/message/27174#27181 · In reply to: #27180

Hi Ilia,

Oh I know that. :-)  I'm just talking about if there's a backslash as the
last character.  For example, date('U\\') (U\ passed after script parsing),
the backslash is gone, which doesn't seem correct...  (Actually, it
"appends" the '\0'.)


Matt


----- Original Message -----
From: "Ilia Alshanetsky"
Sent: Friday, December 22, 2006

> Matt,
>
> The backslash removal is actually intentional. It is designed to
> handle instances such as "\d", in which case the format value is
> printed as a literal "d".
>
>
> 
>
> > […]
>
> Ilia Alshanetsky

---

## #27182 — Ilia Alshanetsky — 2006-12-22T15:28:15+00:00

URL: https://externals.io/message/27174#27182 · In reply to: #27181

I think this is actually a desired behavior, I do not want to change  
how the existing code works in patch level release. Otherwise the  
patch is fine and I've already applied it to the CVS.



> Hi Ilia,
>
> Oh I know that. :-)  I'm just talking about if there's a backslash  
> as the
> last character.  For example, date('U\\') (U\ passed after script  
> parsing),
> the backslash is gone, which doesn't seem correct...  (Actually, it
> "appends" the '\0'.)
>
>
> Matt
>
>
> ----- Original Message -----
> From: "Ilia Alshanetsky"
> Sent: Friday, December 22, 2006
>
> > […]
>
>

Ilia Alshanetsky
