From 75d5888f989435e7410fb5f064d474b6dd2e7d2d Mon Sep 17 00:00:00 2001 From: "Snyder, Emily" Date: Tue, 15 Oct 2024 11:51:12 -0700 Subject: [PATCH 1/2] update node-addon-api and set new version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2215909..1ca0276 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intelcorp/wmi-native-module", - "version": "1.0.1", + "version": "1.0.2", "description": "WMI Native Module", "main": "index.js", "repository": { @@ -11,7 +11,7 @@ "contributors": [], "license": "MIT", "dependencies": { - "node-addon-api": "^7.0.0" + "node-addon-api": "^8.2.1" }, "scripts": { "install": "node-gyp rebuild" From 1f9543060c9d1fbd7862e65225e162adce473322 Mon Sep 17 00:00:00 2001 From: "Snyder, Emily" Date: Mon, 21 Oct 2024 11:19:56 -0700 Subject: [PATCH 2/2] move strings where possible --- src/wmi_wrapper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wmi_wrapper.cpp b/src/wmi_wrapper.cpp index b3fcce6..a35c9ff 100644 --- a/src/wmi_wrapper.cpp +++ b/src/wmi_wrapper.cpp @@ -102,7 +102,7 @@ namespace wmi_wrapper for (size_t i = 0; i < properties.size(); ++i) { std::wstring value = GetPropertyValue(properties[i], class_object); - (*results).push_back(make_pair(properties[i], std::wstring(value))); + (*results).push_back(make_pair(properties[i], std::wstring(std::move(value)))); } return hres; } @@ -141,7 +141,7 @@ namespace wmi_wrapper for (int i = start; i < end; ++i) { std::wstring value = GetPropertyValue(names[i], class_object); - (*results).push_back(make_pair(names[i], std::wstring(value))); + (*results).push_back(make_pair(names[i], std::wstring(std::move(value)))); } hres = SafeArrayUnaccessData(names_array); return hres; @@ -197,7 +197,7 @@ namespace wmi_wrapper { object_result = GetAllPropertyValues(class_objects[i], &result); } - results->push_back(result); + results->push_back(std::move(result)); class_objects[i]->Release(); } @@ -342,7 +342,7 @@ namespace wmi_wrapper { std::string value = param_value.ToString().Utf8Value(); std::wstring wstr_value = ConvertStringToWstring(value); - wstr_properties.push_back(wstr_value); + wstr_properties.push_back(std::move(wstr_value)); } else { @@ -433,14 +433,14 @@ namespace wmi_wrapper WmiQueryParams wstr_params = GetWstrParams(query, properties, env); std::vector results; - HRESULT hres = wmi_wrapper::Query(wmi_namespace.Utf8Value().c_str(), wstr_params, &results); + HRESULT hres = wmi_wrapper::Query(wmi_namespace.Utf8Value().c_str(), std::move(wstr_params), &results); if (FAILED(hres)) { std::string hresStr = std::to_string(hres); Napi::Error::New(env, "Query failed with error code: " + hresStr).ThrowAsJavaScriptException(); } - return ConvertResultsObject(results, env); + return ConvertResultsObject(std::move(results), env); } Napi::Object Init(