Skip to content

Commit

Permalink
Merge pull request #5 from ing-bank/feature/benchmark
Browse files Browse the repository at this point in the history
Add benchmark test and if-statement to prevent unnecessary reflection
  • Loading branch information
survivorbat authored Sep 5, 2023
2 parents c3b317c + 50c1c8c commit 0ca6aa9
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 49 deletions.
5 changes: 5 additions & 0 deletions generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func walkThroughObject(registry LinkRegistry, object any, result any) {
func InjectLinks(registry LinkRegistry, object any) []byte {
rawResponseJson, _ := json.Marshal(object)

// If the registry is empty, don't bother doing any reflection
if len(registry) == 0 {
return rawResponseJson
}

var resultObject any

switch ensureConcrete(reflect.ValueOf(object)).Kind() {
Expand Down
Loading

0 comments on commit 0ca6aa9

Please sign in to comment.