Commits

ZyX_I committed 95fd072

@/commands: Eliminated some unneeded `runcmd' calls

  • Participants
  • Parent commits f028583

Comments (0)

Files changed (3)

plugin/frawor/commands.vim

 "▶1 wrapfunc     :: cmd, fname, fdescr → + :function
 function s:F.wrapfunc(cmd, fname, fdescr)
     if type(a:fdescr)==type({})
-        let a:cmd.f[a:fname[2:]]=call(a:cmd.wrapfunc, [a:fdescr], {})
+        let a:cmd.fs[a:fname[2:]]=call(a:cmd.wrapfunc, [a:fdescr], {})
         let args='a:000'
     else
         let lcomp=len(a:fdescr)
         endif
         let compargs+=[a:cmd.g]
         unlet a:cmd.g
-        let [a:cmd.f[a:fname[2:]], a:cmd.FWCid]=
+        let [a:cmd.fs[a:fname[2:]], a:cmd.FWCid]=
                     \call(s:_f.fwc.compile, compargs, {})
         let args     = '[call(s:F.splitfunc, '.
                     \        'a:000'.
                     \        '{}).curargs]'
     endif
     execute      "function ".a:fname."(...)\n"
-                \"    return call(s:commands.".a:cmd.id.".f.".a:fname[2:].", ".
+                \"    return call(s:commands.".a:cmd.id.".fs.".a:fname[2:].", ".
                 \                 args.", {})\n".
                 \"endfunction"
 endfunction
     if !empty(a:cmd.funs)
         call map(remove(a:cmd.funs, 0, -1),
                     \'s:F.wrapfunc(a:cmd, v:val[0], v:val[1])')
-        if empty(a:cmd.f)
-            unlet a:cmd.f
+        if empty(a:cmd.fs)
+            unlet a:cmd.fs
         endif
     endif
     unlet a:cmd.funs a:cmd.augs
     if type(a:cmd.f)==type({})
         call s:F.loadplugin(a:cmd)
         let a:cmd.f=call(a:cmd.wrapfunc, [a:cmd.f], {})
+        execute 'delcommand' a:cmd.id
+        execute 'command' a:cmd.cmdstring
+        unlet a:cmd.cmdstring
     endif
     return call(a:cmd.f, a:args, {})
 endfunction
                 \'plid': a:plugdict.id,
                 \'augs': [],
                 \'funs': [],
-                \   'f': {},
+                \  'fs': {},
                 \}
     let cmdstring=''
     "▶3 Process *splitfunc
         else
             call s:_f.throw('urepl', a:cid, a:plugdict.id)
         endif
-        let cmdstring.='call s:F.runcmd(s:commands.'.a:cid.', '
         if cmd.rsp is 0
-            let cmdstring.='[<f-args>]'
+            let args='[<f-args>]'
         elseif type(cmd.rsp)==type('')
-            let cmdstring.='s:F.cmdsplit(<q-args>, s:commands.'.a:cid.'.rsp)'
+            let args='s:F.cmdsplit(<q-args>, s:commands.'.a:cid.'.rsp)'
         else
-            let cmdstring.='s:commands.'.a:cid.'.rsp(<q-args>)'
+            let args='s:commands.'.a:cid.'.rsp(<q-args>)'
         endif
-        let cmdstring.=')'
+        if type(a:cstr)==type({})
+            let cmd.cmdstring=cmdstring.
+                        \     'call call(s:commands.'.a:cid.'.f, '.args.', {})'
+            let cmdstring.='call s:F.runcmd(s:commands.'.a:cid.', '.args.')'
+        else
+            let cmdstring.='call call(s:commands.'.a:cid.'.f, '.args.', {})'
+        endif
     endif
     "▲3
     let s:commands[cmd.id]=cmd
         if has_key(a:fdict[cid], 'FWCid')
             call s:_f.fwc.del(a:fdict[cid].FWCid)
         endif
-        if has_key(a:fdict[cid], 'f')
-            for fname in keys(a:fdict[cid].f)
+        if has_key(a:fdict[cid], 'fs')
+            for fname in keys(a:fdict[cid].fs)
                 execute 'delfunction s:'.fname
             endfor
         endif

test/commands-twoload.in

 :let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
 :let g:testfile="plugin/".g:curtest.".vim"
 :source test.vim
+:Abc
 :call FraworUnload(g:testfile[:-5])
 :source test.vim
+:Abc

test/commands-twoload.ok

+$ Abc
+$ Abc
 $ Abc
 $ Abc