Optimize autoload prefix in composer.json #43

Merged
merged 1 commit into from Oct 5, 2012

3 participants

@Slamdunk

By having more specific autoload prefixes it is possible to reduce the number of stat calls made. Also it prevents possible collisions.

Ref: zendframework/zendframework@e58c6cd

@Slamdunk Slamdunk Optimize autoload prefix in composer.json
By having more specific autoload prefixes it is possible to reduce the number of stat calls made. Also it prevents possible collisions.
195ce25
@mikey179
Owner

Thanks for your pull request, but I will not apply it as it does not provide any benefit for vfsStream. The fix you are referencing from Zend Framework indeed improves lookup for Zend Framework, but that's only due to the fact that both defined namespaces start with Zend - by adding the trailing backslash a lookup for classes in the ZendTest namespace is speeded up as it doesn't look into the Zend directories any more. On the other hand, vfsStream defines only one path where files can be looked up, so there's nothing that can be improved here.

@mikey179 mikey179 closed this Oct 4, 2012
@Slamdunk

There's no drawback and only a micro benefit for making namespace more definite.

Every project I've PRed this enhancement, accepted it because it's a (micro)performance boost, take a look at this examples:
symfony/symfony#5627
zendframework/zendframework#2653

Can't see any reason why not to accept a performance increase.

@mikey179
Owner

As @stof explains in symfony/symfony#5627 (comment) there could only be a performance improvement if there would be some other prefix containing org\bovigo\vfs in use. As this isn't the case (and shouldn't be in any other package), no performance improvement can be achieved. I think such performance improvement should be used when applicable, but not be introduced just because we can. On the other hand, if this is the new standard way of doing things...

@Slamdunk

The root namespace in PHP is \ and not [blank space], so I think your namespace is org\bovigo\vfs\ and not org\bovigo\vfs.

@stof

@Slamdunk This does not change anything. Composer matches this as a prefix on the FQCN. Unless you have a library using org\bovigo\vfsbis as namespace, or something like that, you won't see any performance improvement (and if you really have such a namespace, you would only see a performance improvement when checking for non existent classes in org\bovigo\vfsbis as Composer already optimizes the order of the prefixes)

@mikey179
Owner

@Slamdunk Well, technically you specify a prefix in the composer.json file, not a namespace. ;-) But for your perseverance I will reopen and merge. :-)

@mikey179 mikey179 reopened this Oct 5, 2012
@mikey179 mikey179 merged commit ef13845 into mikey179:master Oct 5, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment