Skip to content

unescape optimized#38

Merged
dg merged 2 commits into
nette:masterfrom
dg:pull-unescape
Dec 21, 2014
Merged

unescape optimized#38
dg merged 2 commits into
nette:masterfrom
dg:pull-unescape

Conversation

@dg

@dg dg commented Dec 21, 2014

Copy link
Copy Markdown
Member

Closes #32

@JanTvrdik

Copy link
Copy Markdown
Contributor

Nice! The following seems to have slightly better worse-case:

preg_replace_callback(
    '#(%(?:' . substr(chunk_split(bin2hex($reserved), 2, '|'), 0, -1) . '))++#i',
    function($m) {
        return rawurlencode(strtoupper($m[0]));
    },
    $s
);

On the other hand – its slower for common inputs so probably not worth it.

@dg

dg commented Dec 21, 2014

Copy link
Copy Markdown
Member Author

Reserved characters are rare, so probably not.

dg added a commit that referenced this pull request Dec 21, 2014
@dg dg merged commit cdfd0ab into nette:master Dec 21, 2014
@dg dg deleted the pull-unescape branch December 21, 2014 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants