Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoid use of depset.to_list #441

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading