diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-18 02:41:56 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-18 05:27:40 +0100 |
commit | 10c764c022b1e46c84a3b4d3743a58bd1072b5a5 (patch) | |
tree | 9e37cf690bbeb8e430ddf4340b08f55c6fa78954 /app/Issue.hs | |
parent | 0d96613d9aa41f93ebb440bb1aa383456b49f28f (diff) |
feat: limit the number of FFI calls for extracting comments
This replaces the tree-sitter bindings with a call to a single C
function that traverses the AST.
We expect the query API to be slower than manually traversing the tree
for this particular use case.
This will be addressed in an upcoming commit.
@prerequisite-for add-languages-elm-shell-nix
Diffstat (limited to 'app/Issue.hs')
-rw-r--r-- | app/Issue.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/Issue.hs b/app/Issue.hs index d58d14d..2743f45 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -23,7 +23,6 @@ import Data.Text.Encoding qualified as T import Data.Text.IO qualified as T import Data.Time.Clock (UTCTime (utctDay)) import GHC.Generics (Generic) -import GHC.Int (Int64) import GHC.Records (HasField (..)) import Git (Author (..), Commit (..)) import Git qualified as Git @@ -40,8 +39,8 @@ data Issue = Issue title :: T.Text, file :: FilePath, provenance :: Provenance, - startByte :: Int64, - endByte :: Int64, + startByte :: Int, + endByte :: Int, startPoint :: G.Point, endPoint :: G.Point, tags :: [Tag], @@ -100,7 +99,7 @@ instance HasField "id" Issue T.Text where getText :: Issue -> IO T.Text getText (Issue {..}) = - T.decodeUtf8 . LB.toStrict . LB.take (endByte - startByte) . LB.drop startByte + T.decodeUtf8 . LB.toStrict . LB.take (fromIntegral (endByte - startByte)) . LB.drop (fromIntegral startByte) <$> Git.readTextFileOfBS commitHash file replaceText :: Issue -> T.Text -> IO () |