Instead of evaluating the git branch name+status and g4 client name on each invocation, do it only when the current directory indicates so. Speeds up the prompt response considerably.
Pass g4DirCommonPrefix as a function arguments instead of a common variable.