Skip to content

Commit

Permalink
perf: avoid use of depset.to_list
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Dec 2, 2024
1 parent 437451b commit e22b7a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lint/clang_tidy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ load("//lint/private:lint_aspect.bzl", "LintOptionsInfo", "noop_lint_action", "o
_MNEMONIC = "AspectRulesLintClangTidy"

def _gather_inputs(ctx, compilation_context, srcs):
inputs = srcs + ctx.files._configs + compilation_context.headers.to_list()
inputs = srcs + ctx.files._configs
if (any(ctx.files._global_config)):
inputs.append(ctx.files._global_config[0])
return inputs
return depset(inputs, transitive = [compilation_context.headers])

def _toolchain_env(ctx, user_flags, action_name = ACTION_NAMES.cpp_compile):
cc_toolchain = find_cpp_toolchain(ctx)
Expand Down
5 changes: 2 additions & 3 deletions lint/eslint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def _gather_inputs(ctx, srcs, files):
include_transitive_types = True,
include_npm_sources = True,
)
inputs.extend(js_inputs.to_list())
return inputs
return depset(inputs, transitive = [js_inputs])

def eslint_action(ctx, executable, srcs, stdout, exit_code = None, format = "stylish", env = {}):
"""Create a Bazel Action that spawns an eslint process.
Expand Down Expand Up @@ -184,7 +183,7 @@ def eslint_fix(ctx, executable, srcs, patch, stdout, exit_code, format = "stylis
)

ctx.actions.run(
inputs = _gather_inputs(ctx, srcs, file_inputs) + [patch_cfg],
inputs = depset([patch_cfg], transitive = [_gather_inputs(ctx, srcs, file_inputs)]),
outputs = [patch, stdout, exit_code],
executable = executable._patcher,
arguments = [patch_cfg.path],
Expand Down
3 changes: 1 addition & 2 deletions lint/stylelint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def _gather_inputs(ctx, srcs):
include_transitive_types = False,
include_npm_sources = True,
)
inputs.extend(js_inputs.to_list())
return inputs
return depset(inputs, transitive = [js_inputs])

def stylelint_action(ctx, executable, srcs, stderr, exit_code = None, env = {}, options = []):
"""Spawn stylelint as a Bazel action
Expand Down

0 comments on commit e22b7a0

Please sign in to comment.