Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 1159493007: Refactor word splitting in gles2 command generator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/build_gles2_cmd_buffer.py
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 8ababfe5cb0b131294a17091fbea87ae732c64d8..37946a716b8e64065bbcc4443073492bc2063a0f 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -3898,17 +3898,14 @@ def Grouper(n, iterable, fillvalue=None):
def SplitWords(input_string):
- """Transforms a input_string into a list of lower-case components.
+ """Split by '_' if found, otherwise split at uppercase/numeric chars.
- Args:
- input_string: the input string.
-
- Returns:
- a list of lower-case words.
+ Will split "some_TEXT" into ["some", "TEXT"], "CamelCase" into ["Camel",
+ "Case"], and "Vector3" into ["Vector", "3"].
"""
if input_string.find('_') > -1:
- # 'some_TEXT_' -> 'some text'
- return input_string.replace('_', ' ').strip().lower().split()
+ # 'some_TEXT_' -> 'some TEXT'
+ return input_string.replace('_', ' ').strip().split()
else:
if re.search('[A-Z]', input_string) and re.search('[a-z]', input_string):
# mixed case.
@@ -3917,25 +3914,12 @@ def SplitWords(input_string):
input_string = re.sub('([A-Z])', r' \1', input_string).strip()
# 'Vector3' -> 'Vector 3'
input_string = re.sub('([^0-9])([0-9])', r'\1 \2', input_string)
- return input_string.lower().split()
-
-
-def Lower(words):
- """Makes a lower-case identifier from words.
-
- Args:
- words: a list of lower-case words.
-
- Returns:
- the lower-case identifier.
- """
- return '_'.join(words)
-
+ return input_string.split()
def ToUnderscore(input_string):
"""converts CamelCase to camel_case."""
words = SplitWords(input_string)
- return Lower(words)
+ return '_'.join([word.lower() for word in words])
def CachedStateName(item):
if item.get('cached', False):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698