Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

The Encode and EncodeBatch methods methods unnecessarily require std::string instances

オープン
#95 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
cpp

調査の方向性

revision acbdc5a2 の issue に記載されている公開 Encode および EncodeBatch 宣言から始め、続いてリポジトリ全体にある関連する文字列参照を調査してください。添付された tokenizers-cpp-0.1.1.patch を確認し、API パラメーターが string views を使用した後も、文字列のコピーを必要とせずにプロジェクトがビルドされることを検証してください。

索引モデルが issue の本文から書いたものです。

説明

In projects that use plain C strings or std::string_view, methods like Encode and EncodeBatch construct rather large strings, which increases memory allocations and copies. If these methods are declared to take string views, like shown below, then no extra allocation and copying will be performed.

-  virtual std::vector<int32_t> Encode(const std::string& text) = 0;
+  virtual std::vector<int32_t> Encode(const std::string_view& text) = 0;

Seeing how some pull requests are sitting in the queue for over a year, I won't create one, but you can apply the patch attached to this post to change all string references to string views, which will work for both, strings and string views.

The source at the release tag is broken (see another issue I created), so this patch is against the hash acbdc5a2, and can be applied with this command, assuming it runs in a directory above tokenizers-cpp-0.0.1 (otherwise remove -d tokenizers-cpp-0.0.1).

patch --unified -p1 -d tokenizers-cpp-0.0.1 --input ../patches/tokenizers-cpp-0.0.1.patch

tokenizers-cpp-0.1.1.patch

主要言語
C++
スター
512
フォーク
132
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mlc-ai/tokenizers-cpp のほかの issue

mlc-ai/tokenizers-cpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。