Skip to content

Commit 0a8ebdd

Browse files
committed
Refactor _get_bundle to avoid repeated calls to get_loader
1 parent dc2b5cb commit 0a8ebdd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

webpack_loader/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ def _filter_by_extension(bundle, extension):
3535
yield chunk
3636

3737

38-
def _get_bundle(bundle_name, extension, config):
39-
bundle = get_loader(config).get_bundle(bundle_name)
38+
def _get_bundle(loader, bundle_name, extension):
39+
bundle = loader.get_bundle(bundle_name)
4040
if extension:
4141
bundle = _filter_by_extension(bundle, extension)
4242
return bundle
4343

4444

4545
def get_files(bundle_name, extension=None, config='DEFAULT'):
4646
'''Returns list of chunks from named bundle'''
47-
return list(_get_bundle(bundle_name, extension, config))
47+
loader = get_loader(config)
48+
return list(_get_bundle(loader, bundle_name, extension))
4849

4950

5051
def get_as_tags(bundle_name, extension=None, config='DEFAULT', suffix='', attrs='', is_preload=False):
@@ -58,10 +59,9 @@ def get_as_tags(bundle_name, extension=None, config='DEFAULT', suffix='', attrs=
5859
:return: a list of formatted tags as strings
5960
'''
6061

61-
bundle = _get_bundle(bundle_name, extension, config)
62-
tags = []
63-
6462
loader = get_loader(config)
63+
bundle = _get_bundle(loader, bundle_name, extension)
64+
tags = []
6565

6666
for chunk in bundle:
6767
if chunk['name'].endswith(('.js', '.js.gz')):

0 commit comments

Comments
 (0)