diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2014-09-16 07:56:35 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-09-16 07:56:35 -0500 |
commit | caf449e39f5e7545eeabd567349661450aa8c6e5 (patch) | |
tree | 2a3124e3f72efc76519fe33c681a41301d14d2d9 /compiler/utils/StringBuffer.lhs | |
parent | 52eab67a99dd928204b730355245233fa96fa24d (diff) | |
download | haskell-caf449e39f5e7545eeabd567349661450aa8c6e5.tar.gz |
Return nBytes instead of nextAddr from utf8DecodeChar
Summary:
While researching D176, I came across the following simplification
opportunity:
Not all functions that call utf8DecodeChar actually need the address
of the next char. And some need the 'number of bytes' read. So returning
nBytes instead of nextAddr should save a few addition and subtraction
operations, and makes the code a bit simpler.
Test Plan: it validates
Reviewers: simonmar, ezyang, austin
Reviewed By: austin
Subscribers: simonmar, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D179
Diffstat (limited to 'compiler/utils/StringBuffer.lhs')
-rw-r--r-- | compiler/utils/StringBuffer.lhs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/utils/StringBuffer.lhs b/compiler/utils/StringBuffer.lhs index 50d8443b05..d298457bdd 100644 --- a/compiler/utils/StringBuffer.lhs +++ b/compiler/utils/StringBuffer.lhs @@ -179,8 +179,8 @@ nextChar (StringBuffer buf len (I# cur#)) = inlinePerformIO $ do withForeignPtr buf $ \(Ptr a#) -> do case utf8DecodeChar# (a# `plusAddr#` cur#) of - (# c#, b# #) -> - let cur' = I# (b# `minusAddr#` a#) in + (# c#, nBytes# #) -> + let cur' = I# (cur# +# nBytes#) in return (C# c#, StringBuffer buf len cur') currentChar :: StringBuffer -> Char |