Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for cachedTypeFields (0.27 sec)

  1. src/encoding/json/bench_test.go

    	for nt := 1; nt <= maxTypes; nt *= 10 {
    		// Pre-warm a cache of size nt.
    		clearCache()
    		for _, t := range types[:nt] {
    			cachedTypeFields(t)
    		}
    		b.Run(fmt.Sprintf("HitTypes%d", nt), func(b *testing.B) {
    			b.RunParallel(func(pb *testing.PB) {
    				for pb.Next() {
    					cachedTypeFields(types[0])
    				}
    			})
    		})
    	}
    }
    
    func BenchmarkEncodeMarshaler(b *testing.B) {
    	b.ReportAllocs()
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 15:00:17 UTC 2024
    - 12.5K bytes
    - Viewed (0)
  2. staging/src/k8s.io/apimachinery/third_party/forked/golang/json/fields.go

    		return field{}, false
    	}
    	return fields[0], true
    }
    
    var fieldCache struct {
    	sync.RWMutex
    	m map[reflect.Type][]field
    }
    
    // cachedTypeFields is like typeFields but uses a cache to avoid repeated work.
    func cachedTypeFields(t reflect.Type) []field {
    	fieldCache.RLock()
    	f := fieldCache.m[t]
    	fieldCache.RUnlock()
    	if f != nil {
    		return f
    	}
    
    	// Compute fields without lock.
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Sat Jun 25 16:23:43 UTC 2022
    - 13.1K bytes
    - Viewed (0)
  3. src/encoding/json/encode.go

    		return field{}, false
    	}
    	return fields[0], true
    }
    
    var fieldCache sync.Map // map[reflect.Type]structFields
    
    // cachedTypeFields is like typeFields but uses a cache to avoid repeated work.
    func cachedTypeFields(t reflect.Type) structFields {
    	if f, ok := fieldCache.Load(t); ok {
    		return f.(structFields)
    	}
    	f, _ := fieldCache.LoadOrStore(t, typeFields(t))
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 00:18:55 UTC 2024
    - 36.2K bytes
    - Viewed (0)
  4. src/encoding/json/decode.go

    				d.skip()
    				return nil
    			}
    		}
    		if v.IsNil() {
    			v.Set(reflect.MakeMap(t))
    		}
    	case reflect.Struct:
    		fields = cachedTypeFields(t)
    		// ok
    	default:
    		d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)})
    		d.skip()
    		return nil
    	}
    
    	var mapElem reflect.Value
    	var origErrorContext errorContext
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 00:18:55 UTC 2024
    - 35.3K bytes
    - Viewed (0)
Back to top