optimise literalOsPath
Taking a ShortByteString and using OverloadedStrings should avoid it being converted from a String. The reason there is no IsString instance for OsPath is presumably the bad behavior of IsString for ByteString on unicode btw. But literalOsPath won't be used with unicode in git-annex. Sponsored-by: unqueued
This commit is contained in:
parent
8bafe05500
commit
98a0a9ddff
10 changed files with 23 additions and 7 deletions
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Utility.Tor (
|
||||
OnionPort,
|
||||
OnionAddress(..),
|
||||
|
@ -143,7 +145,7 @@ hiddenServiceHostnameFile appname uid ident =
|
|||
hiddenServiceSocketFile :: AppName -> UserID -> UniqueIdent -> OsPath
|
||||
hiddenServiceSocketFile appname uid ident =
|
||||
varLibDir </> toOsPath appname
|
||||
</> toOsPath (show uid ++ "_" ++ ident) </> toOsPath "s"
|
||||
</> toOsPath (show uid ++ "_" ++ ident) </> literalOsPath "s"
|
||||
|
||||
-- | Parse torrc, to get the socket file used for a hidden service with
|
||||
-- the specified UniqueIdent.
|
||||
|
@ -155,7 +157,7 @@ getHiddenServiceSocketFile _appname uid ident =
|
|||
parse [] = Nothing
|
||||
parse (("HiddenServiceDir":hsdir:[]):("HiddenServicePort":_hsport:hsaddr:[]):rest)
|
||||
| "unix:" `isPrefixOf` hsaddr && hasident (toOsPath hsdir) =
|
||||
Just $ toOsPath $ drop (length "unix:") hsaddr
|
||||
Just $ toOsPath $ drop (length ("unix:" :: String)) hsaddr
|
||||
| otherwise = parse rest
|
||||
parse (_:rest) = parse rest
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue