Open
Conversation
原来的get方法有bug,当缓存过的文件但配置项的名不对时,没有正确的返回false,而get和all的代码重复率太高,完全可以整合重用。
kphcdr
requested changes
Sep 15, 2016
Owner
kphcdr
left a comment
There was a problem hiding this comment.
我觉得不应该把两个方法合并到一起去。因为可能会扩展一个把配置存储在mysql中的功能,这时候对于get和all方法的分开使用的效率会更加明显
Author
|
为什么说get和all分开的效率比较明显?get的前半部分都必须和all一样的,要不然就是验证不够完备,get的复杂度比以前增加1(多了is_null($name) 的判断)。 if(isset(self::$conf[$file][$name])) {
return self::$conf[$file][$name];
else
...这种写法只是看上去效率很高,但实际上如果文件已经缓存过,而 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复get方法的一个bug:当配置文件已缓存而$name不存在时,没有正确返回false。
整合get和all方法:两者的代码相似度太高,可以重用封装一个方法