Skip to content

Commit

Permalink
win7dep: remove hstring_compare, link with OneCore.lib
Browse files Browse the repository at this point in the history
hstring_compare is a wrapper around WindowsCompareStringOrdinal, a
function in combase.dll that we were doing a dynamic dispatch to. This
CL lines to OneCore.lib, and directly calls the function.

Bug: 1402283
Change-Id: I40c2b936379ca4b4e20e6738732a0552e48a5eaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4117314
Reviewed-by: Will Harris <wfh@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108002}
  • Loading branch information
David Bienvenu authored and Chromium LUCI CQ committed Feb 21, 2023
1 parent f84a272 commit 6f9f47c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 122 deletions.
8 changes: 4 additions & 4 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1813,8 +1813,6 @@ component("base") {
"win/event_trace_controller.h",
"win/event_trace_provider.cc",
"win/event_trace_provider.h",
"win/hstring_compare.cc",
"win/hstring_compare.h",
"win/hstring_reference.cc",
"win/hstring_reference.h",
"win/i18n.cc",
Expand Down Expand Up @@ -3421,7 +3419,6 @@ test("base_unittests") {
"win/event_trace_consumer_unittest.cc",
"win/event_trace_controller_unittest.cc",
"win/event_trace_provider_unittest.cc",
"win/hstring_compare_unittest.cc",
"win/hstring_reference_unittest.cc",
"win/i18n_unittest.cc",
"win/map_unittest.cc",
Expand Down Expand Up @@ -3460,7 +3457,10 @@ test("base_unittests") {
sources += [ "win/cet_shadow_stack_unittest.cc" ]
}

libs = [ "ntdll.lib" ]
libs = [
"ntdll.lib",
"onecore.lib",
]
}

if (is_linux || is_chromeos) {
Expand Down
34 changes: 0 additions & 34 deletions base/win/hstring_compare.cc

This file was deleted.

28 changes: 0 additions & 28 deletions base/win/hstring_compare.h

This file was deleted.

46 changes: 0 additions & 46 deletions base/win/hstring_compare_unittest.cc

This file was deleted.

17 changes: 7 additions & 10 deletions base/win/winrt_foundation_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
#include <algorithm>
#include <vector>

#include "base/win/hstring_compare.h"
#include "base/check.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

// This file provides helpers for WinRT types.

namespace base {
namespace win {
namespace internal {
namespace base::win::internal {

// Template tricks needed to dispatch to the correct implementation.
//
Expand Down Expand Up @@ -103,14 +101,15 @@ HRESULT CopyN(
typename std::vector<Microsoft::WRL::ComPtr<T>>::const_iterator first,
unsigned count,
T** result) {
for (unsigned i = 0; i < count; ++i)
for (unsigned i = 0; i < count; ++i) {
CopyTo(*first++, result++);
}
return S_OK;
}

inline bool IsEqual(const HSTRING& lhs, const HSTRING& rhs) {
INT32 result;
HRESULT hr = HStringCompare(lhs, rhs, &result);
HRESULT hr = ::WindowsCompareStringOrdinal(lhs, rhs, &result);
DCHECK(SUCCEEDED(hr));
return result == 0;
}
Expand All @@ -128,7 +127,7 @@ bool IsEqual(const Microsoft::WRL::ComPtr<T>& com_ptr, const T* ptr) {
struct Less {
bool operator()(const HSTRING& lhs, const HSTRING& rhs) const {
INT32 result;
HRESULT hr = HStringCompare(lhs, rhs, &result);
HRESULT hr = ::WindowsCompareStringOrdinal(lhs, rhs, &result);
DCHECK(SUCCEEDED(hr));
return result < 0;
}
Expand All @@ -145,8 +144,6 @@ struct Less {
}
};

} // namespace internal
} // namespace win
} // namespace base
} // namespace base::win::internal

#endif // BASE_WIN_WINRT_FOUNDATION_HELPERS_H_

0 comments on commit 6f9f47c

Please sign in to comment.