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.

Runtime performance: trimMargin

See original GitHub issue

In the current implementation(1.0.3) queries are ran through trimMargin function on each execution, which leads to completely unnecesarry allocations and resource usage.

I understands that it’s not much, but why do it in the first place when it doesn’t provide any benefit from doing so? If someone want’s to read the query in debug, he can just copy it and run through some sqlite formatter. It’s especially bad if you’re doing many small and formatted queries.

It’s even worse on native, since kotlin collections and some operations with them are slow (compared to jvm or other native languages).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
JakeWhartoncommented, Mar 7, 2019

Last night after putting the baby to bed I took a shot at implementing this intrinsic in the Kotlin compiler. I got it working for margin and indent for non-interpolated strings only. Sending a PR to the compiler later today after beefing up the tests.

On Wed, Mar 6, 2019, 4:34 PM Jake Wharton <jakewharton@gmail.com wrote:

Well not doing anything definitely won’t do anything! Yep.

On Wed, Mar 6, 2019 at 4:33 PM Dkhusainov notifications@github.com wrote:

I’m a realist and I don’t think this will do anything for the reasons stated above.

As for the overhead problem, I’ll just make all of my heavy queries a one-liners.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/square/sqldelight/issues/1265#issuecomment-470285573, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEbVgF97z_U8UW1Y6IrHGr8FC1Asyks5vUDQQgaJpZM4bhhDJ .

4reactions
JakeWhartoncommented, Mar 21, 2019

This was merged and will ship in Kotlin 1.3.40.

On Thu, Mar 7, 2019 at 9:41 AM Jake Wharton jakewharton@gmail.com wrote:

Last night after putting the baby to bed I took a shot at implementing this intrinsic in the Kotlin compiler. I got it working for margin and indent for non-interpolated strings only. Sending a PR to the compiler later today after beefing up the tests.

On Wed, Mar 6, 2019, 4:34 PM Jake Wharton <jakewharton@gmail.com wrote:

Well not doing anything definitely won’t do anything! Yep.

On Wed, Mar 6, 2019 at 4:33 PM Dkhusainov notifications@github.com wrote:

I’m a realist and I don’t think this will do anything for the reasons stated above.

As for the overhead problem, I’ll just make all of my heavy queries a one-liners.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/square/sqldelight/issues/1265#issuecomment-470285573, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEbVgF97z_U8UW1Y6IrHGr8FC1Asyks5vUDQQgaJpZM4bhhDJ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Runtime performance: trimMargin #1265 - cashapp/sqldelight
In the current implementation(1.0.3) queries are ran through trimMargin function on each execution, which leads to completely unnecesarry ...
Read more >
trimMargin - Kotlin Programming Language
Trims leading whitespace characters followed by marginPrefix from every line of a source string and removes the first and the last lines if...
Read more >
[raw-strings] Indentation problem - OpenJDK mailing lists
Another possibility is to provide a method like trimMargin() on Kotlin [1] which trims all spaces before a special character (pipe by ...
Read more >
Source Code for Errors.kt - AndroidX Tech
internal object Errors { /** * Same as trimMargins, but add newlines on either ... reduces | runtime performance in order to support...
Read more >
Kotlin 1.3.40 released - The JetBrains Blog
Starting with this release, trimIndent and trimMargin calls are ... Kotlin/JS incremental compilation performance has been improved.
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