Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Nov 1, 2024
1 parent 6beb689 commit 5d7382f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions build-aarch64-linux-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ fi
if [[ x"$SHERPA_ONNX_ENABLE_GPU" == x"" ]]; then
# By default, use CPU
SHERPA_ONNX_ENABLE_GPU=OFF

# If you use GPU, then please make sure you have NVIDIA GPUs on your board.
# It uses onnxruntime 1.11.0.
#
# Tested on Jetson Nano B01
fi

if [[ x"$SHERPA_ONNX_ENABLE_GPU" == x"ON" ]]; then
Expand Down
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <stdio.h>
#include <stdlib.h>

#include <utility>

#if __ANDROID_API__ >= 8
#include "android/log.h"
#define SHERPA_ONNX_LOGE(...) \
Expand Down
17 changes: 8 additions & 9 deletions sherpa-onnx/csrc/symbol-table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@ namespace {
const char *ws = " \t\n\r\f\v";

// trim from end of string (right)
inline std::string &TrimRight(std::string &s, const char *t = ws) {
s.erase(s.find_last_not_of(t) + 1);
return s;
inline void TrimRight(std::string *s, const char *t = ws) {
s->erase(s->find_last_not_of(t) + 1);
}

// trim from beginning of string (left)
inline std::string &TrimLeft(std::string &s, const char *t = ws) {
s.erase(0, s.find_first_not_of(t));
return s;
inline void TrimLeft(std::string *s, const char *t = ws) {
s->erase(0, s->find_first_not_of(t));
}

// trim from both ends of string (right then left)
inline std::string &Trim(std::string &s, const char *t = ws) {
return TrimLeft(TrimRight(s, t), t);
inline void Trim(std::string *s, const char *t = ws) {
TrimRight(s, t);
TrimLeft(s, t);
}
} // namespace

Expand All @@ -56,7 +55,7 @@ std::unordered_map<std::string, int32_t> ReadTokens(
std::string sym;
int32_t id = -1;
while (std::getline(is, line)) {
Trim(line);
Trim(&line);
std::istringstream iss(line);
iss >> sym;
if (iss.eof()) {
Expand Down

0 comments on commit 5d7382f

Please sign in to comment.