question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minifyer skips some variables when written below Main()

See original GitHub issue

I suppose this behavior is expected if it minifies from top-to-bottom, going through A to Z. I tried to see if I could balance characters written and instruction count by writing a sort of library of strings that has to be repeated throughout the script. Since I found it messy to keep the library above Program(), I moved it below Main(). As a result, not all of the variables got abbreviated upon deploy.

string
            _TARGET = "Target",
            _RANGE = "Range",
            _METEORS = "Meteors",
            _MISSILES = "Missiles",
            _SMALLSHIPS = "SmallShips",
            _LARGESHIPS = "LargeShips",
            _CHARACTERS = "Characters",
            _STATIONS = "Stations",
            _NEUTRALS = "Neutrals",
            _ON = "_On",
            _OFF = "_Off",
            _ONOFF = "OnOff",
            _ATMOSPHERIC = "atmospheric",
            _HYDROGEN = "hydrogen",
            _ION = "ion";

string y=“Target”,_RANGE=“Range”,_METEORS=“Meteors”,_MISSILES=“Missiles”,C=“SmallShips”,D=“LargeShips”,E=“Characters”,F=“Stations”,G=“Neutrals”,H=“_On”,_OFF=“_Off”,J=“OnOff”,K=“atmospheric”,L=“hydrogen”,M=“ion”;

When I moved the collection of strings back up to the top, above Program(), it was no longer an issue.

Easiest solution: User writes variables at the top where they are expected to be found procedurally.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
malware-devcommented, Aug 17, 2017

Well I would have preferred if you’d actually zipped your solution, but I can probably make this work 😉

PS: You should probably make those strings const string, I assume they’ll never actually change during runtime.

0reactions
malware-devcommented, Dec 7, 2017

Since the minifier is being completely rewritten from scratch, this issue is no longer relevant.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I skip an if statement inside a function the next time ...
It is possible that some kind of compiler optimization or branch prediction causes it to be skipped on the second call. But that's...
Read more >
Static variable inside of a function in C
There are two issues here, lifetime and scope. The scope of variable is where the variable name can be seen. Here, x is...
Read more >
How to write a good C main function
In this article, I'll explain how to structure a C file and write a C main function that handles command line arguments like...
Read more >
tdewolff/minify: Go minifiers for web formats
Minify is a minifier package written in Go. It provides HTML5, CSS3, JS, JSON, SVG and XML minifiers and an interface to implement...
Read more >
Unit 2: Variables and If
So to make the program above work, we just add a declaration of variable x of type int before the assignment: #include "ic210.h"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found