Miha-x64 / Mikes_IDEA_extensions

IntelliJ IDEA: missing parts.
Apache License 2.0
34 stars 7 forks source link

How to improve the code to avoid "heavyweight property delegation" hint. #54

Closed danny-su closed 1 year ago

danny-su commented 1 year ago
image

The following is the function definition:

inline fun <reified R : Any> arg(
    needLock: Boolean = false,
    noinline converter: (Any) -> R = getDefaultConverter()
) =
    PropertyDelegateProvider<ArgumentProvider, ReadOnlyProperty<ArgumentProvider, R?>> { _, _ ->
        ReadOnlyProperty { thisRef, property ->
            thisRef.getArgument(property.name, needLock, converter)
        }
    }
Miha-x64 commented 1 year ago

https://github.com/Miha-x64/Mikes_IDEA_extensions/issues/52#issuecomment-1669936704

danny-su commented 1 year ago

@Miha-x64 Is there any chance to suppress the inspection message of "expected performance impact ..." for these inline operator functions such as getValue, setValue and provideDelegate?

image
Miha-x64 commented 1 year ago

@danny-su @Suppress("NOTHING_TO_INLINE") (or Alt/Option+Enter → Suppress…)