IsString StringContainingQuotedPath optimisation
authorJoey Hess <joeyh@joeyh.name>
Tue, 11 Apr 2023 19:29:04 +0000 (15:29 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 11 Apr 2023 19:29:04 +0000 (15:29 -0400)
This causes an encodeBS thunk, and the first evaluation of the string
forces it. From then on, further uses operate on a ByteString. This
avoids converting repeatedly.

Git/Filename.hs

index 2e86e9efff20e9bb25e4118187b903de76fdc745..2baea62dc616ca9e388c98a3c0ab5698af999bd0 100644 (file)
@@ -99,7 +99,7 @@ instance Quoteable StringContainingQuotedPath where
        noquote (a :+: b) = noquote a <> noquote b
 
 instance IsString StringContainingQuotedPath where
-       fromString = UnquotedString
+       fromString = UnquotedByteString . encodeBS
 
 instance Sem.Semigroup StringContainingQuotedPath where
        UnquotedString a <> UnquotedString b = UnquotedString (a <> b)