### 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
"""Context manager used to set temporary templating context, without having to worry about resetting
        original values afterward
        Use a keyword that maps to the attr you are setting. Applies to ``self.environment`` by default, to
        set context on another object, it must be in ``mapping``.
        """
        mapping = {
            'available_variables': self,
            'searchpath': self.environment.loader,
        }
        original = {}
        for key, value in kwargs.items():
            obj = mapping.get(key, self.environment)
            try:
                original[key] = getattr(obj, key)
                if value is not None:
                    setattr(obj, key, value)
            except AttributeError:
                
                pass
        yield
        for key in original:
            obj = mapping.get(key, self.environment)
            setattr(obj, key, original[key])
    def template(self, variable, convert_bare=False, preserve_trailing_newlines=True, escape_backslashes=True, fail_on_undefined=None, overrides=None,