<commit_before>import config from '../runtime/config'
import { compile } from '../compiler/index'
import { query, warn } from '../runtime/util/index'
import Vue from './web-runtime'

const mount = Vue.prototype.$mount
const idTemplateCache = Object.create(null)

function idToTemplate (id) {
  const hit = idTemplateCache[id]
  return hit || (idTemplateCache[id] = query(id).innerHTML)
}

Vue.prototype.$mount = function (el) {
  el = el && query(el)
  const options = this.$options
  // resolve template/el and convert to render function
  if (!options.render) {
    let template = options.template
    if (template) {
      if (typeof template === 'string') {
        if (template.charAt(0) === '#') {
          template = idToTemplate(template)
        }
      } else if (template.nodeType) {
        template = template.innerHTML
      } else {
        warn('invalid template option:' + template, this)
      }
    } else if (el) {
      template = getOuterHTML(el)
    }
    if (template) {
      const res = compile(template, {
        preserveWhitespace: config.preserveWhitespace
      })
      options.render = new Function(res.render)
      if (res.staticRenderFns.length) {
        options.staticRenderFns = res.staticRenderFns.map(code => {
          return new Function(code)
        })
      }
    }
  }
  mount.call(this, el)
}

/**
 * Get outerHTML of elements, taking care
 * of SVG elements in IE as well.
 *
 * @param {Element} el<commit_msg>fix runtime mount render function caching<commit_after>import config from '../runtime/config'
import { compile } from '../compiler/index'
import { query, warn } from '../runtime/util/index'
import Vue from './web-runtime'

const mount = Vue.prototype.$mount
const idTemplateCache = Object.create(null)
const renderFunctionCache = Object.create(null)

function idToTemplate (id) {
  const hit = idTemplateCache[id]
  return hit || (idTemplateCache[id] = query(id).innerHTML)
}

function createRenderFn (code) {
  const hit = renderFunctionCache[code]
  return hit || (renderFunctionCache[code] = new Function(code))
}

Vue.prototype.$mount = function (el) {
  el = el && query(el)
  const options = this.$options
  // resolve template/el and convert to render function
  if (!options.render) {
    let template = options.template
    if (template) {
      if (typeof template === 'string') {
        if (template.charAt(0) === '#') {
          template = idToTemplate(template)
        }
      } else if (template.nodeType) {
        template = template.innerHTML
      } else {
        warn('invalid template option:' + template, this)
      }
    } else if (el) {
      template = getOuterHTML(el)
    }
    if (template) {
      const res = compile(template, {
        preserveWhitespace: config.preserveWhitespace
      })
      options.render = createRenderFn(res.render)
      const l = res.staticRenderFns.length
      if (l) {
        options.staticRenderFns = new Array(l)
        for (let i = 0; i < l; i++) {
          options.staticRenderFns[i] = createRenderFn(res.staticRenderFns[i])
        }
      }
    }
  }
  mount.call(this, el)
}

/**
 * Get outerHTML of elements, taking care
 * of SVG elements in IE as well.
 *
 * @param {Element} el
{'fraction_non_alphanumeric': 0.12620453838980417, 'fraction_numerical': 0.0009325458501709667, 'mean_word_length': 2.776995305164319, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4879302', 'n_tokens_mistral': 964, 'n_tokens_neox': 959, 'n_words': 257}