diff options
author | Simon Rozman <simon@rozman.si> | 2020-07-28 12:38:17 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-10-30 16:50:59 +0100 |
commit | af937e52ebcbc9377b4506ecc2e6bf3fb493b7ab (patch) | |
tree | 07b90ac019cdb6b0b2de39f613b94c9d22367549 | |
parent | api: honor locale when comparing case-insensitive (diff) | |
download | wintun-af937e52ebcbc9377b4506ecc2e6bf3fb493b7ab.tar.xz wintun-af937e52ebcbc9377b4506ecc2e6bf3fb493b7ab.zip |
api: make adapter name searching more efficient
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | api/devmgmt.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/api/devmgmt.c b/api/devmgmt.c index 39cc2f7..12862e8 100644 --- a/api/devmgmt.c +++ b/api/devmgmt.c @@ -605,13 +605,16 @@ WintunGetAdapter( continue; /* TODO: is there a better way than comparing ifnames? */ - WCHAR Name2[MAX_ADAPTER_NAME], Name3[MAX_ADAPTER_NAME]; + WCHAR Name2[MAX_ADAPTER_NAME]; if (NciGetConnectionName(&CfgInstanceID, Name2, sizeof(Name2), NULL) != ERROR_SUCCESS) continue; Name2[_countof(Name2) - 1] = 0; - RemoveNumberedSuffix(Name2, Name3); - if (_wcsicmp_l(Name, Name2, Locale) && _wcsicmp_l(Name, Name3, Locale)) - continue; + if (_wcsicmp_l(Name, Name2, Locale)) + { + RemoveNumberedSuffix(Name2, Name2); + if (_wcsicmp_l(Name, Name2, Locale)) + continue; + } /* Check the Hardware ID to make sure it's a real Wintun device. This avoids doing slow operations on non-Wintun * devices. */ |