### 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
ran = wrap_var(ran[0])
                else:
                    ran = wrap_var(ran)
        return ran
    def do_template(self, data, preserve_trailing_newlines=True, escape_backslashes=True, fail_on_undefined=None, overrides=None, disable_lookups=False):
        if self.jinja2_native and not isinstance(data, string_types):
            return data
        
        
        data_newlines = _count_newlines_from_end(data)
        if fail_on_undefined is None:
            fail_on_undefined = self._fail_on_undefined_errors
        try:
            
            if overrides is None:
                myenv = self.environment
            else:
                myenv = self.environment.overlay(overrides)
            
            if hasattr(data, 'startswith') and data.startswith(JINJA2_OVERRIDE):
                eol = data.find('\n')
                line = data[len(JINJA2_OVERRIDE):eol]
                data = data[eol + 1:]
                for pair in line.split(','):
                    (key, val) = pair.split(':')
                    key = key.strip()
                    setattr(myenv, key, ast.literal_eval(val.strip()))
            if escape_backslashes:
                
                data = _escape_backslashes(data, myenv)