Strict `Text` wrapper unnecessarily decodes to `Char` for `text-2.*`

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
haskell
領域
compilers

調査の方向性

data/AlexWrappers.hs の 88-90 行および 98-105 行から始め、alexInputPrevChar と strict Text wrapper の入力処理を追跡してください。wrapper の動作を維持しつつ、issue で説明されている後方への文字境界処理を含め、不要な Text-to-Char デコードを削除してください。

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

説明

Looking at the code:

https://github.com/haskell/alex/blob/e65958c688ba04f8b14c888d7b55f16532510f51/data/AlexWrappers.hs#L88-L90

This can be replaced by:

type AlexInput = (Int,            -- current offset
                  Data.Text.Text) -- input string

https://github.com/haskell/alex/blob/e65958c688ba04f8b14c888d7b55f16532510f51/data/AlexWrappers.hs#L98-L105

This can be replaced by:

alexGetByte :: AlexInput -> Maybe (Byte,AlexInput)
alexGetByte (cur, input) = case input of
  Text arr off len
    | cur < len = Just (unsafeIndex arr (off + curr) (cur + 1, input))
    | otherwise = Nothing

The only thing "complicated" is alexInputPrevChar, basically you go back from cur one byte at a time until you have seen two character boundaries and then do a character decode at that position.

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

環境構築

はじめの一歩

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

haskell/alex のほかの issue

haskell/alex の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

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

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