From 6972d5307f17fac535a264efbc62ce0247310364 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 1 Mar 2020 16:13:30 -0600 Subject: [PATCH] convert confusing query syntax to LINQ expression --- BizHawk.Client.Common/ControllerBinding.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index 8f957847cb..8562725963 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -43,18 +43,17 @@ namespace BizHawk.Client.Common public bool this[string button] => IsPressed(button); // Looks for bindings which are activated by the supplied physical button. - public List SearchBindings(string button) - { - return (from kvp in _bindings from boundButton in kvp.Value where boundButton == button select kvp.Key).ToList(); - } + public List SearchBindings(string button) => + _bindings + .Where(b => b.Value.Any(v => v == button)) + .Select(b => b.Key) + .ToList(); // Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller - public bool HasBinding(string button) - { - return _bindings + public bool HasBinding(string button) => + _bindings .SelectMany(kvp => kvp.Value) .Any(boundButton => boundButton == button); - } public void NormalizeFloats(IController controller) {