### Summary

`ansible.template.is_template` tries to loop until it determines if the value is indeed a template.  Which means we could loop extremely large strings, that don't even remotely look like templates, before we bail.

However, we could benefit from moving `Templar.is_possibly_template` to the global scope, and testing whether the value after `jinja_env.preprocess` is even possibly a template, before doing more computationally complex validation.

### Issue Type

Feature Idea

### Component Name

lib/ansible/template/__init__.py

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
raise
        except Exception as ex:
            display.warning('an unexpected error occurred during Jinja2 environment setup: {0}'.format(to_native(ex)))
            display.vvv('exception during Jinja2 environment setup: {0}'.format(format_exc()))
            raise TemplateSyntaxError(to_native(ex), 0)
    def __setitem__(self, key, value):
        return self._delegatee.__setitem__(key, value)
    def __delitem__(self, key):
        raise NotImplementedError()
    def __iter__(self):
        
        return iter(self._delegatee)
    def __len__(self):
        
        return len(self._delegatee)
class AnsibleEnvironment(Environment):
    '''
    Our custom environment, which simply allows us to override the class-level
    values for the Template and Context classes used by jinja2 internally.
    NOTE: Any changes to this class must be reflected in
          :class:`AnsibleNativeEnvironment` as well.
    '''
    context_class = AnsibleContext
    template_class = AnsibleJ2Template
    def __init__(self, *args, **kwargs):
        super(AnsibleEnvironment, self).__init__(*args, **kwargs)
        self.filters = JinjaPluginIntercept(self.filters, filter_loader, jinja2_native=False)
        self.tests = JinjaPluginIntercept(self.tests, test_loader, jinja2_native=False)
if USE_JINJA2_NATIVE:
    class AnsibleNativeEnvironment(NativeEnvironment):