summaryrefslogtreecommitdiff
path: root/compiler/utils/StringBuffer.lhs
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2014-09-16 07:56:35 -0500
committerAustin Seipp <austin@well-typed.com>2014-09-16 07:56:35 -0500
commitcaf449e39f5e7545eeabd567349661450aa8c6e5 (patch)
tree2a3124e3f72efc76519fe33c681a41301d14d2d9 /compiler/utils/StringBuffer.lhs
parent52eab67a99dd928204b730355245233fa96fa24d (diff)
downloadhaskell-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.lhs4
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