Text plugin code cleanup:
Do not declare variables you do not need if you return anyway.
Use prefix instead of postfix increments.
Merged if condition checks.
Declaration and assignment of variables in one line.
Added and removed newlines.
Removed redundant brackets.
Fixed indentation.
Approved by PS Jenkins bot, Sam Spilsbury.