Skip to content

Commit

Permalink
perf: avoid use of depset.to_list (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored Dec 3, 2024
1 parent a58bea5 commit 6ade9f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 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 Expand Up @@ -349,7 +349,7 @@ def clang_tidy_fix(ctx, compilation_context, executable, srcs, patch, stdout, ex
)

ctx.actions.run(
inputs = _gather_inputs(ctx, compilation_context, srcs) + [patch_cfg],
inputs = depset([patch_cfg], transitive = [_gather_inputs(ctx, compilation_context, srcs)]),
outputs = [patch, stdout, exit_code],
executable = executable._patcher,
arguments = [patch_cfg.path],
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
5 changes: 2 additions & 3 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 Expand Up @@ -145,7 +144,7 @@ def stylelint_fix(ctx, executable, srcs, patch, stderr, exit_code, env = {}, opt
)

ctx.actions.run(
inputs = _gather_inputs(ctx, srcs) + [patch_cfg],
inputs = depset([patch_cfg], transitive = [_gather_inputs(ctx, srcs)]),
outputs = [patch, stderr, exit_code],
executable = executable._patcher,
arguments = [patch_cfg.path],
Expand Down

0 comments on commit 6ade9f8

Please sign in to comment.