-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[switch_utils.c] fix switch_cut_path() function for both slash and back slash in path #770
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@andywolk Could you help to review this change please? Thanks |
|
This changes behavior of the function when either using mixed / and \ or when using unix delims on windows. If you want to optimize this function the first step would be to do a set of unit tests including those scenarios. Is there a compelling reason to optimize this function, if so please provide some detail of the scenario that has this function being called frequently |
|
any optimization or refactoring type changes should start with a complete set of unit tests to confirm we don’t break anything in the process. |
9f4cbd5 to
d9fdc2b
Compare
d9fdc2b to
c1f6041
Compare
|
@mjerris I turn on all level log, and the |
|
does the new way will break cutting unix style paths on windows? |
|
Hi @mjerris The updated changes won't break cutting unix style paths on windows. The changes didn't depend on the macro |
|
The unit testing case will verify it's behavior. freeswitch/tests/unit/switch_utils.c Lines 65 to 68 in c1f6041
|
|
@mjerris The new version released days ago, shall we merge this bug fix then it will get wide testing before next release? Thanks |
|
@mjerris Could you review this bug fix please? It will fix the incorrect path spliting on *nix, and keep behavior on Windows. |
Hi,
This change try to rewrite the
switch_cut_path()function, for continue search the next sep with preview stopping position, while the original function will always try both two path-seps from beginning.The new implemention will
fix problem to deal some path like
a\\b/cwith both back slash and slash.$ mkdir a\\b/ && cd a\\b/ && git clone URL_FSOriginal function will give unexpect value
bwhile new implemention will return expect valuea\\b.reduce about 40% calling timing.
$ gcc -std=c11 test-switch_cut_path.c && ./a.outfunc[0] take time 9 sfunc[1] take time 15 sThe testing code is