NVMeBasicContext: Allocate streambuf where it's used
Move it after the early-exits to avoid useless (de)allocation.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I31264eb01342bbf40ed88b23aadd34eae43957cd
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index 93802b9..e06a0a7 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -246,8 +246,6 @@
void NVMeBasicContext::readAndProcessNVMeSensor()
{
- auto response = std::make_shared<boost::asio::streambuf>();
-
if (sensors.empty())
{
return;
@@ -285,6 +283,7 @@
}
});
+ auto response = std::make_shared<boost::asio::streambuf>();
response->prepare(1);
/* Gather the response and dispatch for parsing */