ZyX_I avatar ZyX_I committed 479ac37

@aurum/log: Removed one-line function that is called only once
@aurum/log/templates: Inlined addlines function
@aurum/log, @aurum/log/templates: Removed some string() calls (seems it was not an optimization at all)

Comments (0)

Files changed (2)

plugin/aurum/log.vim

 "▶1 addcols
 function s:F.addcols(special, cnum)
     let mapexpr='[v:val[0], v:val[1]+'.a:cnum.']+v:val[2:]'
-    call map(a:special, 'v:key[-2:] is? "_r"?'.
-                \             'map(v:val, '.string(mapexpr).'):'.
-                \             mapexpr)
-    return a:special
+    call map(a:special, 'v:key[-2:] is? "_r" ? map(v:val, mapexpr) : '.mapexpr)
 endfunction
 "▶1 gettext :: skip, cs, opts, repo, width → Text
 let s:skiptext={'skip': 1, 'text': [], 'special': {}}
     let nmorecols=len(a:seen)-ncols
     return [nodeidx, edges, ncols, nmorecols]
 endfunction
-"▶2 glog.fix_long_right_edges
-function s:F.glog.fix_long_right_edges(edges)
-    call map(a:edges, '((v:val[1]>v:val[0])?([v:val[0], v:val[1]+1]):(v:val))')
-endfunction
 "▶2 glog.get_nodeline_edges_tail
 function s:F.glog.get_nodeline_edges_tail(node_index, p_node_index, n_columns,
             \                             n_columns_diff, p_diff, fix_tail)
     let add_padding_line=0
     let lnum = (has_key(text, 'text') ? len(text.text) : 0)
     if coldiff==-1
-        call s:F.glog.fix_long_right_edges(edges)
+        call map(edges, '((v:val[1]>v:val[0])?([v:val[0],v:val[1]+1]):(v:val))')
         if lnum>2
             let add_padding_line=!empty(filter(copy(edges),
                         \                      '(v:val[0]+1)<v:val[1]'))

plugin/aurum/log/templates.vim

     let r.=string(a:template)[2:-3]
     return r
 endfunction
-"▶2 addlines
-function s:F.addlines(special, lnum)
-    let mapexpr='[v:val[0]+'.a:lnum.']+v:val[1:]'
-    call map(a:special, 'v:key[-2:] is? "_r"?'.
-                \             'map(v:val, '.string(mapexpr).'):'.
-                \             mapexpr)
-    return a:special
-endfunction
 "▶1 strappend :: func, String → + func
 let s:setlstrstr='let lstr=remove(text, -1)'
 let s:addexpr='((eval(submatch(1))!=0)?'.
                 \   (has_key(a:arg, 'flbeg')?
                 \       ['let ntext[0]='.string(a:arg.flbeg).'.ntext[0]']:
                 \       [])+[
-                \'call s:F.addlines(sp, len(text))',
+                \'let mapexpr="[v:val[0]+".len(text)."]+v:val[1:]"',
+                \'call map(sp, "v:key[-2:] is? ''_r'' ? map(v:val, mapexpr) '.
+                \                                    ': ".mapexpr)',
                 \'let text+=ntext',
                 \'call extend(special, sp)']
     if addedif2
     endif
     "▲3
     let func+=['let ntext='.a:expr,
-                \'call map(ntext, string(lstr).".v:val")']+
+                \'call map(ntext, "lstr.v:val")']+
                 \   (has_key(a:arg, 'flbeg')?
                 \       ['let ntext[0]='.string(a:arg.flbeg).
                 \                                  '.ntext[0]']:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.