summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 23:19:17 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 23:19:17 +0000
commit2cb0c4539c1352c55b6fc844a9ece58dd3f962ac (patch)
tree0e86d2c44b4c34a7449259cf2a7ce9e26cdbefc7 /third_party
parente35da7489de6f9ce605a5895f47040fa8bbe9613 (diff)
downloadchromium_src-2cb0c4539c1352c55b6fc844a9ece58dd3f962ac.zip
chromium_src-2cb0c4539c1352c55b6fc844a9ece58dd3f962ac.tar.gz
chromium_src-2cb0c4539c1352c55b6fc844a9ece58dd3f962ac.tar.bz2
Improve performance of extension docs generation by 60%.
Review URL: http://codereview.chromium.org/9996002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/json_minify/README.chromium3
-rw-r--r--third_party/json_minify/__init__.py5
-rw-r--r--third_party/json_minify/minify_json.py113
3 files changed, 1 insertions, 120 deletions
diff --git a/third_party/json_minify/README.chromium b/third_party/json_minify/README.chromium
index 0f5f630..019c326 100644
--- a/third_party/json_minify/README.chromium
+++ b/third_party/json_minify/README.chromium
@@ -11,7 +11,6 @@ Description:
A set of scripts that remove comments and whitespace from JSON files.
Local Modifications:
-- Added the __init__.py file for easier imports
- Got the (much faster) json-minify-sans-regexp.js file from the second
URL listed
-- Small change to minify_json.py to pass license tests
+- Removed minify_json.py, it is crazy slow. See commit for replacement.
diff --git a/third_party/json_minify/__init__.py b/third_party/json_minify/__init__.py
deleted file mode 100644
index 45bce20..0000000
--- a/third_party/json_minify/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from minify_json import json_minify
diff --git a/third_party/json_minify/minify_json.py b/third_party/json_minify/minify_json.py
deleted file mode 100644
index 69aac6e..0000000
--- a/third_party/json_minify/minify_json.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Use of this source code is governed by a BSD-style license (MIT)
-'''
-Created on 20/01/2011
-
-v0.1 (C) Gerald Storer
-MIT License
-
-Based on JSON.minify.js:
-https://github.com/getify/JSON.minify
-'''
-
-import re
-
-def json_minify(json,strip_space=True):
- tokenizer=re.compile('"|(/\*)|(\*/)|(//)|\n|\r')
- in_string = False
- in_multiline_comment = False
- in_singleline_comment = False
-
- new_str = []
- from_index = 0 # from is a keyword in Python
-
- for match in re.finditer(tokenizer,json):
-
- if not in_multiline_comment and not in_singleline_comment:
- tmp2 = json[from_index:match.start()]
- if not in_string and strip_space:
- tmp2 = re.sub('[ \t\n\r]*','',tmp2) # replace only white space defined in standard
- new_str.append(tmp2)
-
- from_index = match.end()
-
- if match.group() == '"' and not in_multiline_comment and not in_singleline_comment:
- escaped = re.search('(\\\\)*$',json[:match.start()])
- if not in_string or escaped is None or len(escaped.group()) % 2 == 0:
- # start of string with ", or unescaped " character found to end string
- in_string = not in_string
- from_index -= 1 # include " character in next catch
-
- elif match.group() == '/*' and not in_string and not in_multiline_comment and not in_singleline_comment:
- in_multiline_comment = True
- elif match.group() == '*/' and not in_string and in_multiline_comment and not in_singleline_comment:
- in_multiline_comment = False
- elif match.group() == '//' and not in_string and not in_multiline_comment and not in_singleline_comment:
- in_singleline_comment = True
- elif (match.group() == '\n' or match.group() == '\r') and not in_string and not in_multiline_comment and in_singleline_comment:
- in_singleline_comment = False
- elif not in_multiline_comment and not in_singleline_comment and (
- match.group() not in ['\n','\r',' ','\t'] or not strip_space):
- new_str.append(match.group())
-
- new_str.append(json[from_index:])
- return ''.join(new_str)
-
-if __name__ == '__main__':
- import json # requires Python 2.6+ to run tests
-
- def test_json(s):
- return json.loads(json_minify(s))
-
- test1 = '''// this is a JSON file with comments
-{
- "foo": "bar", // this is cool
- "bar": [
- "baz", "bum", "zam"
- ],
-/* the rest of this document is just fluff
- in case you are interested. */
- "something": 10,
- "else": 20
-}
-
-/* NOTE: You can easily strip the whitespace and comments
- from such a file with the JSON.minify() project hosted
- here on github at http://github.com/getify/JSON.minify
-*/
-'''
-
- test1_res = '''{"foo":"bar","bar":["baz","bum","zam"],"something":10,"else":20}'''
-
- test2 = '''
-{"/*":"*/","//":"",/*"//"*/"/*/"://
-"//"}
-
-'''
- test2_res = '''{"/*":"*/","//":"","/*/":"//"}'''
-
- test3 = r'''/*
-this is a
-multi line comment */{
-
-"foo"
-:
- "bar/*"// something
- , "b\"az":/*
-something else */"blah"
-
-}
-'''
- test3_res = r'''{"foo":"bar/*","b\"az":"blah"}'''
-
- test4 = r'''{"foo": "ba\"r//", "bar\\": "b\\\"a/*z",
- "baz\\\\": /* yay */ "fo\\\\\"*/o"
-}
-'''
- test4_res = r'''{"foo":"ba\"r//","bar\\":"b\\\"a/*z","baz\\\\":"fo\\\\\"*/o"}'''
-
- assert test_json(test1) == json.loads(test1_res),'Failed test 1'
- assert test_json(test2) == json.loads(test2_res),'Failed test 2'
- assert test_json(test3) == json.loads(test3_res),'Failed test 3'
- assert test_json(test4) == json.loads(test4_res),'Failed test 4'
- if __debug__: # Don't print passed message if the asserts didn't run
- print 'Passed all tests'