Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/34: More compact array/map representation #43

Closed
wants to merge 11 commits into from

Conversation

komuw
Copy link
Contributor

@komuw komuw commented May 20, 2021

What:

  • Where the elements in a slice/array are primitive types; dump in a compact manner.
  • Where the elements(not keys) in a map are primitive types; dump in a compact manner

Why:

@komuw komuw changed the title Issues/34: More compact array representation Issues/34: More compact array/map representation May 20, 2021
Copy link
Member

@atombender atombender left a comment

Choose a reason for hiding this comment

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

My concern here is wrapping. If you have a slice or map of a certain number of elements, they are going to all be on the same line.

I looked at implementing a compact mode for slices/maps at one point, but ran into the problem that you need to handle wrapping and indentation everywhere, and I didn't bother finishing it. Ideally, indentation and wrapping should be handled at the writer level.

case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.String:
// Where the elements in a slice/array are primitive types; dump in a compact manner
original := s.config.Compact
s.config.Compact = true
Copy link
Member

Choose a reason for hiding this comment

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

We should never mutate the configuration, which might be shared across multiple concurrent goroutines, and might be a constant at the caller's end. Let's add the flag to dumpState directly.

@komuw
Copy link
Contributor Author

komuw commented May 23, 2021

I have given this a little more thought. I think the work needed here is a little more than I had imagined.
I don't think I'll be able to get to it anytime soon; thus I'm electing to close this PR.

litter is a tool that has saved me a lot of minutes and I would like to take this moment to thank all who work on it. Thank you.

@komuw komuw closed this May 23, 2021
@atombender
Copy link
Member

Thank you! I might revisit this at some point. It's annoying, I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More compact array representation
2 participants