Skip to content

Commit

Permalink
Revert "Increase JSON->EDN processing times for API calls by ~23x"
Browse files Browse the repository at this point in the history
This reverts commit 506b972.
  • Loading branch information
JonathanHarford committed Oct 8, 2019
1 parent 506b972 commit 7a2dc32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
3 changes: 1 addition & 2 deletions project.clj
Expand Up @@ -39,8 +39,7 @@
[com.cemerick/url "0.1.1"]
[overtone/at-at "1.2.0"]
[camel-snake-kebab "0.4.0"]
[org.clojure/spec.alpha "0.2.176"]
[cljs-bean "1.5.0"]]
[org.clojure/spec.alpha "0.2.176"]]
:repositories [["private" {:url "s3p://mayvenn-dependencies/releases/"}]]
:plugins [[s3-wagon-private "1.3.1"]
[lein-cljsbuild "1.1.7"]
Expand Down
23 changes: 6 additions & 17 deletions src-cljs/storefront/api.cljs
Expand Up @@ -12,8 +12,7 @@
[spice.maps :as maps]
[spice.core :as spice]
[clojure.set :as set]
[storefront.effects :as effects]
[cljs-bean.core :refer [->clj]]))
[storefront.effects :as effects]))

(defn is-rails-style? [resp]
(or (seq (:error resp))
Expand Down Expand Up @@ -89,27 +88,17 @@
(let [default (ajax/json-response-format config)
read-json (:read default)]
(assoc default :read (fn [xhrio]
{:body (->clj (read-json xhrio))
{:body (read-json xhrio)
:app-version (app-version xhrio)}))))

(defn json-response-format [config]
(let [default (ajax/json-response-format config)
read-json (:read default)]
(assoc default :read (fn [xhrio]
{:body (->clj (read-json xhrio))}))))

(def default-req-opts
{:format :json
:response-format (json-response-format-with-app-version
;; We're handling all the post-JSON.parse processing since
;; we can get a significant performance improvement by
;; using cljs-bean over js->clj
;;
;; :keywords? false => ~3x perf improvement over js->clj
;; :raw true => ~5x perf improvement over :keywords? false
;; -> ~27x perf improvement over js->clj
{:keywords? false
:raw true})})
{:body (read-json xhrio)}))))

(def default-req-opts {:format :json
:response-format (json-response-format-with-app-version {:keywords? true})})

(defn- wrap-api-end [req-key req-id handler]
(fn [response]
Expand Down
5 changes: 2 additions & 3 deletions src-cljs/storefront/frontend_effects.cljs
Expand Up @@ -46,8 +46,7 @@
[storefront.routes :as routes]
[storefront.components.share-links :as share-links]
[storefront.components.popup :as popup]
[spice.core :as spice]
[cljs-bean.core :refer [->clj]]))
[spice.core :as spice]))

(defn changed? [previous-app-state app-state keypath]
(not= (get-in previous-app-state keypath)
Expand Down Expand Up @@ -85,7 +84,7 @@
:choices
js/decodeURIComponent
js/JSON.parse
->clj)]
(js->clj :keywordize-keys true))]
(messages/handle-message events/control-adventure-choice {:choice {:value choices}}))
(quadpay/insert)
(svg/insert-sprite)
Expand Down
5 changes: 2 additions & 3 deletions src-cljs/storefront/platform/asset_mappings.cljs
@@ -1,6 +1,5 @@
(ns storefront.platform.asset-mappings
(:require [cljs-bean.core :refer [->clj]]))
(ns storefront.platform.asset-mappings)

(def cdn-host js/cdnHost)

(def manifest (->clj js/assetManifest))
(def manifest (js->clj js/assetManifest))

1 comment on commit 7a2dc32

@corey
Copy link
Member

@corey corey commented on 7a2dc32 Oct 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonathanHarford @jeffh What happened here?

Please sign in to comment.