@@ -15,7 +15,6 @@ import (
1515 "path/filepath"
1616 "time"
1717
18- "github.com/gopherjs/gopherjs/build/cache/pack"
1918 log "github.com/sirupsen/logrus"
2019)
2120
@@ -28,8 +27,6 @@ import (
2827type Cacheable interface {
2928 Write (encode func (any ) error ) error
3029 Read (decode func (any ) error ) error
31- pack.Packable
32- pack.Unpackable
3330}
3431
3532// Cache defines methods to store and load cacheable objects.
@@ -219,22 +216,21 @@ func (bc *BuildCache) Load(c Cacheable, importPath string, srcModTime time.Time)
219216 return true
220217}
221218
222- var encoding = `pack`
219+ // encoding is the encoding to use when serializing and deserializing the cache.
220+ // Possible values are seen in `getSerializer` and `getDeserializer`.
221+ // Using zip provides a CRC check for the data and reduces the file size but it is slightly slower.
222+ var encoding = `json`
223223
224224type serializeHandle func (c Cacheable , buildTime time.Time , w io.Writer ) (err error )
225225type deserializeHandle func (c Cacheable , srcModTime time.Time , r io.Reader ) (buildTime time.Time , old bool , err error )
226226
227227func (bc * BuildCache ) getSerializer () serializeHandle {
228228 switch encoding {
229- case `pack` :
230- return bc .packSerialize
231229 case `json` :
232230 return bc .jsonSerialize
233231 case `gob` :
234232 return bc .gobSerialize
235- case `zipPack` :
236- return zipGobSerialize (bc .packSerialize )
237- case `zipJaon` :
233+ case `zipJson` :
238234 return zipGobSerialize (bc .jsonSerialize )
239235 case `zipGob` :
240236 return zipGobSerialize (bc .gobSerialize )
@@ -245,14 +241,10 @@ func (bc *BuildCache) getSerializer() serializeHandle {
245241
246242func (bc * BuildCache ) getDeserializer () deserializeHandle {
247243 switch encoding {
248- case `pack` :
249- return bc .packDeserialize
250244 case `json` :
251245 return bc .jsonDeserialize
252246 case `gob` :
253247 return bc .gobDeserialize
254- case `zipPack` :
255- return zipGobDeserialize (bc .packDeserialize )
256248 case `zipJson` :
257249 return zipGobDeserialize (bc .jsonDeserialize )
258250 case `zipGob` :
@@ -329,25 +321,6 @@ func (bc *BuildCache) jsonDeserialize(c Cacheable, srcModTime time.Time, r io.Re
329321 return buildTime , false , c .Read (decode )
330322}
331323
332- func (bc * BuildCache ) packSerialize (c Cacheable , buildTime time.Time , w io.Writer ) (err error ) {
333- e := pack .NewEncoder (w )
334- if err = e .EncodeTime (buildTime ); err != nil {
335- return err
336- }
337- return c .PackEncode (e )
338- }
339-
340- func (bc * BuildCache ) packDeserialize (c Cacheable , srcModTime time.Time , r io.Reader ) (buildTime time.Time , old bool , err error ) {
341- d := pack .NewDecoder (r )
342- if err := d .DecodeTime (& buildTime ); err != nil {
343- return buildTime , false , err
344- }
345- if srcModTime .After (buildTime ) {
346- return buildTime , true , nil // Package is out-of-date, cache miss.
347- }
348- return buildTime , false , c .PackDecode (d )
349- }
350-
351324// commonKey returns a part of the cache key common for all artifacts generated
352325// under a given BuildCache configuration.
353326func (bc * BuildCache ) commonKey () string {
0 commit comments