On 2020-06-15, dylnmc wrote: > @brammool I have been following this issue, and I was hoping that there could > be an optional parameter to remove all forward slashes at the front except for > the first one. > > This is because I am using paths as keys to a dictionary, and without simplify > () removing all leading duplicate forward slashes, there is no good option > than > adding unnecessary stuff. > > These are the best two ways of doing it without this optional "remove all > prefixed duplicate forward slashes": > > • let foo = function({ path -> simplify(path[:0] is '/' ? '//'..path : path) > }(expand(a:path) > • let foo = substitute(simplify(expand(a:path)), '^/\{2.}', '/', '') > > I am not a big fan of either of these happening many times per second in a > loop > or in a repeatedly called function. let foo = simplify(a:path, v:true) is much > more preferable.
So what is the measured performance difference of let foo = simplify(expand(a:path) vs. let foo = substitute(simplify(expand(a:path)), '^/\{2.}', '/', '') in your application? Regards, Gary -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20200615210200.GD29345%40phoenix.