pbx/pbx_loopback: Speed up switches by avoiding unneeded lookups

This patch makes a small rearrangement to only do dialplan lookups during
loopback switches if the pattern matches. Prior to this patch, the dialplan
lookups were always performed, even when the result would be discarded.
Dialplan lookups can be very costly if remote switches - like DUNDi - are
present. In those cases extension matching is sped up considerably, making
the issue of lost digits more manageable.

As collateral damage, 6 trailing spaces were killed.

Review: https://reviewboard.asterisk.org/r/4211

ASTERISK-24577 #close
Reported by: Birger Harzenetter
patches:
  ast-loopback.patch uploaded by Birger Harzenetter (License 5870)
........

Merged revisions 428787 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 428788 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 428789 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@428790 f38db490-d61c-443f-a65b-d21fe96a405b