git-annex/Utility
Joey Hess 5c960601aa 4 ns optimisation of repeated calls to hasDifference on the same Differences
I want this as fast as possible, so it can be added to code paths without
slowing them down.

Avoid the set lookup, and rely on laziness,
drops runtime from 14.37 ns to 11.03 ns according to this criterion benchmark:

import Criterion.Main
import qualified Types.Difference as New
import qualified Types.DifferenceOld as Old

main :: IO ()
main = defaultMain
	[ bgroup "hasDifference"
		[ bench "new" $ whnf (New.hasDifference New.OneLevelObjectHash) new
		, bench "old" $ whnf (Old.hasDifference Old.OneLevelObjectHash) old
		]
	]
  where
	s = "fromList [ObjectHashLower, OneLevelObjectHash, OneLevelBranchHash]"
	new = New.readDifferences s
	old = Old.readDifferences s

A little bit of added boilerplate, but I suppose it's worth it to not
need to worry about set lookup overhead. Note that adding more differences
would slow down the old implementation; the new implementation will run
the same speed.
2015-06-11 16:34:35 -04:00
..
DirWatcher update my email address and homepage url 2015-01-21 12:50:09 -04:00
LockFile need more polymorphism 2015-05-22 13:50:37 -04:00
LockPool AMP hack 2015-05-31 16:54:07 -04:00
Applicative.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Base64.hs Replace dataenc with sandi. 2015-05-07 18:07:05 -04:00
Batch.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Bloom.hs switch to Control.Monad.ST to avoid build warning in ghc 7.10 2015-05-10 14:42:16 -04:00
CoProcess.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
CopyFile.hs fsck --from remote: When bad content is found in the remote, and the local repo does not have a copy of the content, preserve the bad content in .git/annex/bad/ to avoid further data loss. 2015-04-18 14:13:07 -04:00
Daemon.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Data.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
DataUnits.hs info: Added --bytes option. 2015-04-12 14:08:40 -04:00
DBus.hs Revert "When listing DBus services, also list activatable services." 2015-06-02 14:38:24 -04:00
Directory.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
DirWatcher.hs removed all uses of undefined from code base 2015-04-19 00:38:29 -04:00
DiskFree.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Dot.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
DottedVersion.hs more {-# OPTIONS_GHC -fno-warn-tabs #-} ... Forcing people who have what is merely a difference of opinion to you to do this is a bit of an asshole move. Just saying. 2015-05-10 16:38:49 -04:00
Env.hs more {-# OPTIONS_GHC -fno-warn-tabs #-} ... Forcing people who have what is merely a difference of opinion to you to do this is a bit of an asshole move. Just saying. 2015-05-10 16:38:49 -04:00
Exception.hs implment catchHardwareFault 2015-05-27 16:36:54 -04:00
ExternalSHA.hs fsck: When checksumming a file fails due to a hardware fault, the file is now moved to the bad directory, and the fsck proceeds. Before, the fsck immediately failed. 2015-05-27 16:40:03 -04:00
FileMode.hs honor core.sharedRepository settings in lockContent 2015-05-19 14:53:19 -04:00
FileSize.hs build fix 2015-01-20 17:27:42 -04:00
FileSystemEncoding.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Format.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
FreeDesktop.hs more {-# OPTIONS_GHC -fno-warn-tabs #-} ... Forcing people who have what is merely a difference of opinion to you to do this is a bit of an asshole move. Just saying. 2015-05-10 16:38:49 -04:00
Glob.hs qualify imports to avoid conflict with regex-tdfa-rc 2015-05-30 02:03:09 -04:00
Gpg.hs two more breakages introduced when removing the Params constructor 2015-06-03 13:02:33 -04:00
Hash.hs refactor 2015-04-19 10:57:14 -04:00
HumanNumber.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
HumanTime.hs rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
InodeCache.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
JSONStream.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
libdiskfree.c update my email address and homepage url 2015-01-21 12:50:09 -04:00
libdiskfree.h Renamed diskfree.c to avoid OSX case insensativity bug. 2012-04-13 11:26:39 -04:00
libkqueue.c update my email address and homepage url 2015-01-21 12:50:09 -04:00
libkqueue.h fix prototype 2012-06-19 01:57:19 -04:00
libmounts.c update my email address and homepage url 2015-01-21 12:50:09 -04:00
libmounts.h Got removable media mount detection working on Android. 2013-05-04 16:19:25 -04:00
LinuxMkLibs.hs rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
LockFile.hs use lock pools throughout git-annex 2015-05-19 14:09:52 -04:00
LockPool.hs lock pools to work around non-concurrency/composition safety of POSIX fcntl 2015-05-18 15:57:17 -04:00
LogFile.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Lsof.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Matcher.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Metered.hs removed all uses of undefined from code base 2015-04-19 00:38:29 -04:00
Misc.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Monad.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Mounts.hsc rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
Network.hs more {-# OPTIONS_GHC -fno-warn-tabs #-} ... Forcing people who have what is merely a difference of opinion to you to do this is a bit of an asshole move. Just saying. 2015-05-10 16:38:49 -04:00
NotificationBroadcaster.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
OSX.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Parallel.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
PartialPrelude.hs more {-# OPTIONS_GHC -fno-warn-tabs #-} ... Forcing people who have what is merely a difference of opinion to you to do this is a bit of an asshole move. Just saying. 2015-05-10 16:38:49 -04:00
Path.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Percentage.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
PID.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
PosixFiles.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Process.hs merge haddock formatting from propellor 2015-05-30 11:27:40 -04:00
QuickCheck.hs rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
Quvi.hs fix bug introduced in recent Params removal 2015-06-02 16:28:05 -04:00
Rsync.hs remove Params constructor from Utility.SafeCommand 2015-06-01 13:52:23 -04:00
SafeCommand.hs remove Params constructor from Utility.SafeCommand 2015-06-01 13:52:23 -04:00
Scheduled.hs rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
Shell.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
SimpleProtocol.hs WIP on making --quiet silence progress, and infra for concurrent progress bars 2015-04-03 16:48:30 -04:00
SRV.hs rejigger imports for clean build with ghc 7.10's AMP changes 2015-05-10 16:20:30 -04:00
SshConfig.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Tense.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
ThreadLock.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
ThreadScheduler.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
TList.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Tmp.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Touch.hsc removed all uses of undefined from code base 2015-04-19 00:38:29 -04:00
URI.hs 4 ns optimisation of repeated calls to hasDifference on the same Differences 2015-06-11 16:34:35 -04:00
Url.hs remove Params constructor from Utility.SafeCommand 2015-06-01 13:52:23 -04:00
UserInfo.hs disable horrible tab warning, needed in every file that Setup.hs pulls in 2015-05-10 16:31:50 -04:00
Verifiable.hs Removed dependency on haskell SHA library, instead using cryptohash >= 0.11.0. 2015-04-19 11:05:32 -04:00
WebApp.hs Dropped support for older versions of yesod and warp than the ones in Debian Jessie. 2015-04-22 16:19:11 -04:00
winprocess.c windows: Fix process termination code. 2014-02-13 15:53:10 -04:00
WinProcess.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Yesod.hs Dropped support for older versions of yesod and warp than the ones in Debian Jessie. 2015-04-22 16:19:11 -04:00