aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-14 21:36:15 +0800
committerGitHub <noreply@github.com>2023-01-14 21:36:15 +0800
commit2065ce877ef81bcd66132bd26e75aa4d761dca12 (patch)
tree875ab83390eb34fc6d85b5b43c35600166eac56d /src/nvim/mark.c
parentd549734fb4792bcdb5395006538f7c6d856252e7 (diff)
downloadrneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.tar.gz
rneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.tar.bz2
rneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.zip
vim-patch:partial:9.0.1196: code is indented more than necessary (#21796)
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11813) https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8 Partial port as this depends on some previous eval and 'smoothscroll' patches. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/mark.c')
-rw-r--r--src/nvim/mark.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 830ad8e729..b98935e93d 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -653,29 +653,31 @@ fmark_T *getnextmark(pos_T *startpos, int dir, int begin_line)
// until the mark is used to avoid a long startup delay.
static void fname2fnum(xfmark_T *fm)
{
- if (fm->fname != NULL) {
- // First expand "~/" in the file name to the home directory.
- // Don't expand the whole name, it may contain other '~' chars.
+ if (fm->fname == NULL) {
+ return;
+ }
+
+ // First expand "~/" in the file name to the home directory.
+ // Don't expand the whole name, it may contain other '~' chars.
#ifdef BACKSLASH_IN_FILENAME
- if (fm->fname[0] == '~' && (fm->fname[1] == '/' || fm->fname[1] == '\\')) {
+ if (fm->fname[0] == '~' && (fm->fname[1] == '/' || fm->fname[1] == '\\')) {
#else
- if (fm->fname[0] == '~' && (fm->fname[1] == '/')) {
+ if (fm->fname[0] == '~' && (fm->fname[1] == '/')) {
#endif
- expand_env("~/", NameBuff, MAXPATHL);
- int len = (int)strlen(NameBuff);
- xstrlcpy(NameBuff + len, fm->fname + 2, (size_t)(MAXPATHL - len));
- } else {
- xstrlcpy(NameBuff, fm->fname, MAXPATHL);
- }
+ expand_env("~/", NameBuff, MAXPATHL);
+ int len = (int)strlen(NameBuff);
+ xstrlcpy(NameBuff + len, fm->fname + 2, (size_t)(MAXPATHL - len));
+ } else {
+ xstrlcpy(NameBuff, fm->fname, MAXPATHL);
+ }
- // Try to shorten the file name.
- os_dirname(IObuff, IOSIZE);
- char *p = path_shorten_fname(NameBuff, IObuff);
+ // Try to shorten the file name.
+ os_dirname(IObuff, IOSIZE);
+ char *p = path_shorten_fname(NameBuff, IObuff);
- // buflist_new() will call fmarks_check_names()
- (void)buflist_new(NameBuff, p, (linenr_T)1, 0);
- }
+ // buflist_new() will call fmarks_check_names()
+ (void)buflist_new(NameBuff, p, (linenr_T)1, 0);
}
// Check all file marks for a name that matches the file name in buf.