You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "szaszm (via GitHub)" <gi...@apache.org> on 2023/06/07 21:26:26 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1584: MINIFICPP-1755 - Use std::span instead of gsl::span

szaszm commented on code in PR #1584:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1584#discussion_r1222182466


##########
libminifi/include/utils/crypto/ciphers/Aes256Ecb.h:
##########
@@ -50,8 +50,8 @@ class Aes256EcbCipher {
   static constexpr size_t KEY_SIZE = 32;
 
   explicit Aes256EcbCipher(Bytes encryption_key);
-  void encrypt(gsl::span<unsigned char /*, BLOCK_SIZE*/> data) const;
-  void decrypt(gsl::span<unsigned char /*, BLOCK_SIZE*/> data) const;
+  void encrypt(std::span<unsigned char /*, BLOCK_SIZE*/> data) const;
+  void decrypt(std::span<unsigned char /*, BLOCK_SIZE*/> data) const;

Review Comment:
   Maybe we could change to a fixed extent span here?



##########
libminifi/test/TestBase.cpp:
##########
@@ -645,7 +645,7 @@ std::string TestPlan::getContent(const minifi::core::FlowFile& file) const {
   auto content_stream = content_repo_->read(*content_claim);
   auto output_stream = std::make_shared<minifi::io::BufferStream>();
   minifi::InputStreamPipe{*output_stream}(content_stream);
-  return utils::span_to<std::string>(output_stream->getBuffer().as_span<const char>());
+  return std::string{reinterpret_cast<const char*>(output_stream->getBuffer().data()), output_stream->size()};

Review Comment:
   I'd prefer to keep following the as_span<const char> -> span_to<string> pattern here as well.



##########
libminifi/test/unit/GslTest.cpp:
##########
@@ -1,35 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vector>
-#include <string>
-#include "../TestBase.h"
-#include "../Catch.h"
-#include "utils/gsl.h"
-
-namespace utils = org::apache::nifi::minifi::utils;
-
-TEST_CASE("span to", "[span to]") {
-  const auto test_span = gsl::make_span("test text", 9);
-  const auto string = utils::span_to<std::string>(test_span);
-  const auto vector = utils::span_to<std::vector>(test_span);
-
-  REQUIRE(string == "test text");
-  REQUIRE('t' == vector[0]);
-  REQUIRE(9 == vector.size());
-}

Review Comment:
   why is this deleted? we should also add tests for as_span.



##########
libminifi/test/rocksdb-tests/SwapTests.cpp:
##########
@@ -57,7 +57,7 @@ class OutputProcessor : public core::Processor {
     auto ff = session->create();
     ff->addAttribute("index", id);
     session->write(ff, [&] (const std::shared_ptr<minifi::io::OutputStream>& output) -> int64_t {
-      auto ret = output->write(gsl::span<const char>(id.data(), id.size()).as_span<const std::byte>());
+      auto ret = output->write(as_bytes(std::span<const char>(id.data(), id.size())));

Review Comment:
   Could we skip the explicit `std::span` construction, and just rely on implicit conversion from `string` to `span` in the argument of `as_bytes`?
   ```suggestion
         auto ret = output->write(as_bytes(id));
   ```



##########
libminifi/include/utils/gsl.h:
##########
@@ -32,18 +33,23 @@ using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>
 }  // namespace detail
 
 template<typename Container, typename T>
-Container span_to(gsl::span<T> span) {
+Container span_to(std::span<T> span) {

Review Comment:
   Please check the definition as well. There are still references to `gsl::span` in the assertions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org