mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-12 18:45:58 +00:00
Text.Pandoc.Class.PandocMonad: avoid copying input in toTextM.
Skip the CR-filtering copy when the input contains no CRs, as already done in Text.Pandoc.UTF8.toText. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
762d6384b2
commit
cbbbf312ea
@@ -479,7 +479,11 @@ toTextM fp bs =
|
||||
if "\xEF\xBB\xBF" `B.isPrefixOf` bs'
|
||||
then B.drop 3 bs'
|
||||
else bs'
|
||||
filterCRs = B.filter (/=13)
|
||||
-- Only allocate a filtered copy if a CR is actually present;
|
||||
-- B.elem compiles to a fast memchr.
|
||||
filterCRs bs' = if 13 `B.elem` bs'
|
||||
then B.filter (/=13) bs'
|
||||
else bs'
|
||||
|
||||
-- | Returns @fp@ if the file exists in the current directory; otherwise
|
||||
-- searches for the data file relative to @/subdir/@. Returns @Nothing@
|
||||
|
||||
Reference in New Issue
Block a user