From f3e2d5a59983a5cb8c364dbac169fa5ef16ebb51 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 30 May 2020 19:39:29 +0530 Subject: Optimize weather plugin by reusing manager and other refactors As documented in the http-client library, calling newManager is an expensive operation: ``` Creating a new Manager is a relatively expensive operation, you are advised to share a single Manager between requests instead. ``` But inspite of the haddocks in xmobar claiming that once 'Manager' is created, it will be used throughout the monitor is not true. Because for every call of `startWeather` a new manager is being created. Also I removed the option in WeatherOpts because even if it is false, it will be ultimately created in `getData` function. Also without using a manager - the plugin won't really work. So, I don't think there is any reason for this option to exist. I have introduced a new dependency http-client-tls to use the shared global manager so that we reuse the same manager every time. This simplifies a lot of code. Note that this is not really a new dependency because http-conduit already depends on it transitively. --- xmobar.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmobar.cabal') diff --git a/xmobar.cabal b/xmobar.cabal index 5dcd770..d52c460 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -263,7 +263,7 @@ library if flag(with_weather) || flag(all_extensions) other-modules: Xmobar.Plugins.Monitors.Weather cpp-options: -DWEATHER - build-depends: http-conduit, http-types + build-depends: http-conduit, http-types, http-client-tls if flag(with_uvmeter) other-modules: Xmobar.Plugins.Monitors.UVMeter -- cgit v1.2.3