From f5e2fde47388fce5e23bf6f4abee0ae860a2e022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Mon, 27 May 2019 21:10:35 +0200 Subject: Update FastString docstrings 1) FastStrings are always UTF-8 encoded now. 2) Clarify what is meant by "hashed" 3) Add mention of lazy z-enc --- compiler/utils/FastString.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'compiler/utils/FastString.hs') diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index 662b6db79d..7749c3f7c3 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -171,20 +171,22 @@ mkFastZStringString str = FastZString (BSC.pack str) -- ----------------------------------------------------------------------------- -{-| -A 'FastString' is an array of bytes, hashed to support fast O(1) -comparison. It is also associated with a character encoding, so that -we know how to convert a 'FastString' to the local encoding, or to the -Z-encoding used by the compiler internally. +{-| A 'FastString' is a UTF-8 encoded string together with a unique ID. All +'FastString's are stored in a global hashtable to support fast O(1) +comparison. -'FastString's support a memoized conversion to the Z-encoding via zEncodeFS. +It is also associated with a lazy reference to the Z-encoding +of this string which is used by the compiler internally. -} - data FastString = FastString { uniq :: {-# UNPACK #-} !Int, -- unique id n_chars :: {-# UNPACK #-} !Int, -- number of chars fs_bs :: {-# UNPACK #-} !ByteString, - fs_zenc :: FastZString -- lazily computed z-encoding of this string + fs_zenc :: FastZString + -- ^ Lazily computed z-encoding of this string. + -- + -- Since 'FastString's are globally memoized this is computed at most + -- once for any given string. } instance Eq FastString where -- cgit v1.2.1