]> git.puffer.fish Git - mirror/frr.git/commit
vtysh: optimize printout routine 1611/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 8 Jan 2018 21:40:49 +0000 (16:40 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 8 Jan 2018 21:55:36 +0000 (16:55 -0500)
commit08ee8e223170edc764118eb6c303ee70a702b6bd
treeb5ca4c9fc53fbc60f894e413de8e4aadf04bb816
parent4060fcc47b537d49e7801371ddedf9828c94366a
vtysh: optimize printout routine

When printing responses from a client, vtysh searches through every
response it receives twice. Once is to look for the terminating
sequence and the other is to translate \n to \0, which is used with the
line processing callback capability. However:

* There's no need to search all of the output for the terminator, we can
  just check the last 4 bytes.
* In most scenarios we won't have a callback. Therefore we don't need to
  process the output and can just dump it.

Together these optimizations have a significant impact on the total
runtime of talkative CLI commands, such as `sh ip bgp json` which runs
roughly 1000% faster when dumping 1,000,000 routes.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
vtysh/vtysh.c