It's faster as :buf
won't reload the file from disk, whereas :edit
will, which is different behaviour.
This is why it's slightly slower in some cases. For most purposes, this is not a huge issue, although it can be over NFS connections, or with larger files. The performance should be identical when opening files that are not yet loaded by Vim.
You can test/benchmark this with e.g. testing.vim:
fun! s:mkbuf()
new
call setline(1, repeat('a', 1048576)) " 1M
silent w! test
endfun
fun! Benchmark_Buf() abort
call s:mkbuf()
let l:buf = bufnr('')
close
for i in range(0, g:bench_n)
exe printf('buffer %d', l:buf)
close
endfor
endfun
fun! Benchmark_Edit() abort
call s:mkbuf()
let l:buf = bufname('')
close
for i in range(0, g:bench_n)
exe printf('edit %s', l:buf)
close
endfor
endfun
Which gives me:
$ tvim test -b . .
Benchmark_Edit 0.599s
Benchmark_Buf 0.027s
That's a difference for 100 000 runs of the above code, so the actual difference for one invocation is about 0.00000006s for a 1M file.