Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Yaml] save preg_match() calls when possible#28106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromxabbuh:issue-27960
Aug 2, 2018

Conversation

@xabbuh
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketspossibly#27960
LicenseMIT
Doc PR

dmaicher and apfelbox reacted with hooray emoji
@xabbuh
Copy link
MemberAuthor

This is how it looks like:

Parsing theservices.yaml file from the FrameworkBundle recipe:

bildschirmfoto 2018-08-01 um 20 45 06

(see
https://blackfire.io/profiles/compare/b59c7350-088d-4a74-be43-45a39152ce89/graph)

Executing the Yaml component test suite:

bildschirmfoto 2018-08-01 um 20 49 28

(seehttps://blackfire.io/profiles/compare/b2f2e6a6-87d3-40ad-95dd-52a2ba6bdda7/graph)

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commite6bea97 intosymfony:masterAug 2, 2018
fabpot added a commit that referenced this pull requestAug 2, 2018
This PR was merged into the 4.2-dev branch.Discussion----------[Yaml] save preg_match() calls when possible| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | possibly#27960| License       | MIT| Doc PR        |Commits-------e6bea97 save preg_match() calls when possible
@staabm
Copy link
Contributor

@xabbuh why does it save so much time in IOWait? The changes are not IO related..

@xabbuhxabbuh deleted the issue-27960 branchAugust 2, 2018 13:39
$context ='sequence';

if (isset($values['value']) &&self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u',$values['value'],$matches)) {
if (isset($values['value']) &&'&' ===$values['value'][0] &&self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u',$values['value'],$matches)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is it possible to have$values['value'] being the empty string here or no ? If yes, we have a bug.

Copy link
MemberAuthor

@xabbuhxabbuhAug 2, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No, the regular expression that has to match to reach this part of the code is#^\-((?P<leadspaces>\s+)(?P<value>.+))?$#u. So if thevalue element is set, it must have at least on character.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yeah, thevalue group can indeed not be empty when it is matched, so things are fine.

privatefunctionisBlockScalarHeader():bool
{
return (bool)self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~',$this->currentLine);
return'' !==$this->currentLine &&(bool)self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~',$this->currentLine);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

what about adding&& \in_array($this->currentLine[0], array('|', '>'), true) && here too ?

Copy link
MemberAuthor

@xabbuhxabbuhAug 2, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thought about that too, but the regular expression should also match lines likefoo: | orfoo: >2, shouldn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

hmm indeed. This regex is not anchored at the start. I missed that

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I just remembered that I indeed tried to add that check and was wondering now why tests didn't fail then. Turns out this method is totally useless with the current code (see#28187).

@stof
Copy link
Member

stof commentedAug 2, 2018

@staabm probably cold vs warm OPCache cache (and so bypassing the IO for many files)

@xabbuh
Copy link
MemberAuthor

@staabm I think what@stof said. You can see updated profile comparisons athttps://blackfire.io/profiles/compare/9de46b73-d563-4e0e-a81a-553cc3d5f290/graph (parsing theservices.yaml file) andhttps://blackfire.io/profiles/compare/6effa0a7-6309-465e-a9a5-fb1863b96813/graph (running the Yaml component test suite).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

7 participants

@xabbuh@fabpot@staabm@stof@nicolas-grekas@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp