Skip to content

Commit 45e16bc

Browse files
authored
Performance tweaks for to_camel_case (#131)
* Perf tweaks for to_camel_case * Address lint
1 parent 6271020 commit 45e16bc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

azure/functions/decorators/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
from typing import TypeVar, Optional, Union, Iterable, Type, Callable
99

1010
T = TypeVar("T", bound=Enum)
11-
SNAKE_CASE_RE = re.compile(r'^([a-z]+\d*_[a-z\d_]*|_+[a-z\d]+[a-z\d_]*)$',
12-
re.IGNORECASE)
13-
WORD_RE = re.compile(r'^([a-z]+\d*)$', re.IGNORECASE)
11+
SNAKE_CASE_RE = re.compile(r'^([a-zA-Z]+\d*_|_+[a-zA-Z\d])\w*$')
12+
WORD_RE = re.compile(r'^([a-zA-Z]+\d*)$')
1413

1514

1615
class StringifyEnum(Enum):
@@ -133,7 +132,7 @@ def to_camel_case(snake_case_str: str):
133132
f"Please ensure {snake_case_str} is a word or snake case "
134133
f"string with underscore as separator.")
135134
words = snake_case_str.split('_')
136-
return words[0] + ''.join(ele.title() for ele in words[1:])
135+
return words[0] + ''.join([ele.title() for ele in words[1:]])
137136

138137

139138
def is_snake_case(input_string: str) -> bool:

0 commit comments

Comments
 (0)