package cache

import (
	

	
	
	
	
	
)
This cache intends to avoid unnecessarily re-parsing files in subsequent builds. For a given path, parsing can be avoided if the contents of the file and the options for the parser are the same as last time. Even if the contents of the file are the same, the options for the parser may have changed if they depend on some other file ("package.json" for example). This cache checks if the file contents have changed even though we have the ability to detect if a file has changed on the file system by reading its metadata. First of all, if the file contents are cached then they should be the same pointer, which makes the comparison trivial. Also we want to cache the AST for plugins in the common case that the plugin output stays the same.
////////////////////////////////////////////////////////////////////////////// CSS
Check the cache
	 := func() *cssCacheEntry {
		.mutex.Lock()
		defer .mutex.Unlock()
		return .entries[.KeyPath]
	}()
Cache hit
	if  != nil && .source ==  && .options ==  {
		for ,  := range .msgs {
			.AddMsg()
		}
		return .ast
	}
Cache miss
	 := logger.NewDeferLog()
	 := css_parser.Parse(, , )
	 := .Done()
	for ,  := range  {
		.AddMsg()
	}
Create the cache entry
	 = &cssCacheEntry{
		source:  ,
		options: ,
		ast:     ,
		msgs:    ,
	}
Save for next time
	.mutex.Lock()
	defer .mutex.Unlock()
	.entries[.KeyPath] = 
	return 
}
////////////////////////////////////////////////////////////////////////////// JSON
Check the cache
	 := func() *jsonCacheEntry {
		.mutex.Lock()
		defer .mutex.Unlock()
		return .entries[.KeyPath]
	}()
Cache hit
	if  != nil && .source ==  && .options ==  {
		for ,  := range .msgs {
			.AddMsg()
		}
		return .expr, .ok
	}
Cache miss
	 := logger.NewDeferLog()
	,  := js_parser.ParseJSON(, , )
	 := .Done()
	for ,  := range  {
		.AddMsg()
	}
Create the cache entry
	 = &jsonCacheEntry{
		source:  ,
		options: ,
		expr:    ,
		ok:      ,
		msgs:    ,
	}
Save for next time
	.mutex.Lock()
	defer .mutex.Unlock()
	.entries[.KeyPath] = 
	return , 
}
////////////////////////////////////////////////////////////////////////////// JS
Check the cache
	 := func() *jsCacheEntry {
		.mutex.Lock()
		defer .mutex.Unlock()
		return .entries[.KeyPath]
	}()
Cache hit
	if  != nil && .source ==  && .options.Equal(&) {
		for ,  := range .msgs {
			.AddMsg()
		}
		return .ast, .ok
	}
Cache miss
	 := logger.NewDeferLog()
	,  := js_parser.Parse(, , )
	 := .Done()
	for ,  := range  {
		.AddMsg()
	}
Create the cache entry
	 = &jsCacheEntry{
		source:  ,
		options: ,
		ast:     ,
		ok:      ,
		msgs:    ,
	}
Save for next time
	.mutex.Lock()
	defer .mutex.Unlock()
	.entries[.KeyPath] = 
	return ,