better performances of ox.js.minify
This commit is contained in:
parent
46278349e3
commit
c2de06d9d8
2 changed files with 11 additions and 2 deletions
7
ox/js.py
7
ox/js.py
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import sys
|
||||
|
||||
from ox.utils import json
|
||||
|
||||
|
|
@ -8,6 +9,12 @@ def minify(source, comment=''):
|
|||
# see https://github.com/douglascrockford/JSMin/blob/master/README
|
||||
def get_next_non_whitespace_token():
|
||||
pass
|
||||
# python2 performance with unicode string is terrible
|
||||
if sys.version[0] == '2':
|
||||
if isinstance(source, unicode):
|
||||
source = source.encode('utf-8')
|
||||
if isinstance(comment, unicode):
|
||||
comment = comment.encode('utf-8')
|
||||
tokens = tokenize(source)
|
||||
length = len(tokens)
|
||||
minified = '/*' + comment + '*/' if comment else ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue