Skip to content

Commit

Permalink
Simplify selects.apply
Browse files Browse the repository at this point in the history
Summary: Simplify implementation of `selects.apply` by using lambdas instead of using `_apply_helper` and `native.partial`. This will make it easier for me to implement caching in follow-up diffs.

Reviewed By: dtolnay

Differential Revision: D68939126

fbshipit-source-id: 60e6772d5be55793d1d21bfd8e5a3c590ab4bd00
  • Loading branch information
Scott Cao authored and facebook-github-bot committed Feb 4, 2025
1 parent db720c6 commit 593f5df
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions prelude/utils/selects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ _SELECT_TYPE = type(select({"DEFAULT": []}))
def _is_select(thing):
return type(thing) == _SELECT_TYPE

def _apply_helper(function, inner):
if not _is_select(inner):
return function(inner)
return _apply(inner, function)

def _apply(obj, function):
"""
If the object is a select, runs `select_map` with `function`.
Expand All @@ -24,7 +19,7 @@ def _apply(obj, function):
return function(obj)
return select_map(
obj,
partial(_apply_helper, function),
lambda obj: _apply(obj, function),
)

selects = struct(
Expand Down

0 comments on commit 593f5df

Please sign in to comment.