Avoid conversions from std::string to char* to std::string

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2023-11-11 10:38:44 +01:00
parent c69065c360
commit d2d1ff565c
11 changed files with 16 additions and 17 deletions

View File

@ -19,7 +19,7 @@
namespace tesseract {
Maxpool::Maxpool(const char *name, int ni, int x_scale, int y_scale)
Maxpool::Maxpool(const std::string &name, int ni, int x_scale, int y_scale)
: Reconfig(name, ni, x_scale, y_scale) {
type_ = NT_MAXPOOL;
no_ = ni;

View File

@ -2,7 +2,6 @@
// File: maxpool.h
// Description: Standard Max-Pooling layer.
// Author: Ray Smith
// Created: Tue Mar 18 16:28:18 PST 2014
//
// (C) Copyright 2014, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
@ -29,7 +28,7 @@ namespace tesseract {
class Maxpool : public Reconfig {
public:
TESS_API
Maxpool(const char *name, int ni, int x_scale, int y_scale);
Maxpool(const std::string &name, int ni, int x_scale, int y_scale);
~Maxpool() override = default;
// Accessors.

View File

@ -264,7 +264,7 @@ Network *Network::CreateFromFile(TFile *fp) {
network = new LSTM(name, ni, no, no, false, type);
break;
case NT_MAXPOOL:
network = new Maxpool(name.c_str(), ni, 0, 0);
network = new Maxpool(name, ni, 0, 0);
break;
// All variants of Parallel.
case NT_PARALLEL:
@ -272,10 +272,10 @@ Network *Network::CreateFromFile(TFile *fp) {
case NT_PAR_RL_LSTM:
case NT_PAR_UD_LSTM:
case NT_PAR_2D_LSTM:
network = new Parallel(name.c_str(), type);
network = new Parallel(name, type);
break;
case NT_RECONFIG:
network = new Reconfig(name.c_str(), ni, 0, 0);
network = new Reconfig(name, ni, 0, 0);
break;
// All variants of reversed.
case NT_XREVERSED:
@ -284,11 +284,11 @@ Network *Network::CreateFromFile(TFile *fp) {
network = new Reversed(name, type);
break;
case NT_SERIES:
network = new Series(name.c_str());
network = new Series(name);
break;
case NT_TENSORFLOW:
#ifdef INCLUDE_TENSORFLOW
network = new TFNetwork(name.c_str());
network = new TFNetwork(name);
#else
tprintf("TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n");
#endif
@ -302,7 +302,7 @@ Network *Network::CreateFromFile(TFile *fp) {
case NT_LOGISTIC:
case NT_POSCLIP:
case NT_SYMCLIP:
network = new FullyConnected(name.c_str(), ni, no, type);
network = new FullyConnected(name, ni, no, type);
break;
default:
break;

View File

@ -31,7 +31,7 @@
namespace tesseract {
// ni_ and no_ will be set by AddToStack.
Parallel::Parallel(const char *name, NetworkType type) : Plumbing(name) {
Parallel::Parallel(const std::string &name, NetworkType type) : Plumbing(name) {
type_ = type;
}

View File

@ -27,7 +27,7 @@ class Parallel : public Plumbing {
public:
// ni_ and no_ will be set by AddToStack.
TESS_API
Parallel(const char *name, NetworkType type);
Parallel(const std::string &name, NetworkType type);
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).

View File

@ -20,7 +20,7 @@
namespace tesseract {
Reconfig::Reconfig(const char *name, int ni, int x_scale, int y_scale)
Reconfig::Reconfig(const std::string &name, int ni, int x_scale, int y_scale)
: Network(NT_RECONFIG, name, ni, ni * x_scale * y_scale)
, x_scale_(x_scale)
, y_scale_(y_scale) {}

View File

@ -31,7 +31,7 @@ namespace tesseract {
class Reconfig : public Network {
public:
TESS_API
Reconfig(const char *name, int ni, int x_scale, int y_scale);
Reconfig(const std::string &name, int ni, int x_scale, int y_scale);
~Reconfig() override = default;
// Returns the shape output from the network given an input shape (which may

View File

@ -25,7 +25,7 @@
namespace tesseract {
// ni_ and no_ will be set by AddToStack.
Series::Series(const char *name) : Plumbing(name) {
Series::Series(const std::string &name) : Plumbing(name) {
type_ = NT_SERIES;
}

View File

@ -27,7 +27,7 @@ class Series : public Plumbing {
public:
// ni_ and no_ will be set by AddToStack.
TESS_API
explicit Series(const char *name);
explicit Series(const std::string &name);
~Series() override = default;
// Returns the shape output from the network given an input shape (which may

View File

@ -29,7 +29,7 @@ using tensorflow::TensorShape;
namespace tesseract {
TFNetwork::TFNetwork(const char *name) : Network(NT_TENSORFLOW, name, 0, 0) {}
TFNetwork::TFNetwork(const std::string &name) : Network(NT_TENSORFLOW, name, 0, 0) {}
int TFNetwork::InitFromProtoStr(const std::string &proto_str) {
if (!model_proto_.ParseFromString(proto_str))

View File

@ -34,7 +34,7 @@ namespace tesseract {
class TFNetwork : public Network {
public:
explicit TFNetwork(const char *name);
explicit TFNetwork(const std::string &name);
virtual ~TFNetwork() = default;
// Returns the required shape input to the network.