Add dart2js hints to methods that should be inlined.
Cloned from CL 237870386 by 'g4 patch'.
Original change by deboer@deboer:mar11-plural:4158:citc on 2019/03/11 13:30:51.
Without these hints, dart2js is less likely to inline the function. In those cases, the "desc" field will be shipped in the dart2js binary.
PiperOrigin-RevId: 265158154
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 720558a..b2f49e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
## 0.16.0
* Fix 'k' formatting (1 to 24 hours) which incorrectly showed 0 to 23.
* Tighten up types in a couple of places.
+ * Add dart2js pragmas for inlining to help remove descriptions and other
+ compile-time information from the output.
## 0.15.8
* Add return type to some internal methods to improve dart2js output.
diff --git a/lib/intl.dart b/lib/intl.dart
index 67453c4..1eb9f82 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -171,6 +171,10 @@
/// the extracted message output. This can be useful to set up placeholder
/// messages during development whose text aren't finalized yet without having
/// the placeholder automatically translated.
+ @pragma('dart2js:tryInline')
+ // We want dart2js to try to inline these messages, but not inline the
+ // internal messages, so it will eliminate the descriptions and other
+ // information not neeeded at runtime.
static String message(String message_str,
{String desc: '',
Map<String, Object> examples,
@@ -182,6 +186,7 @@
_message(message_str, locale, name, args, meaning);
/// Omit the compile-time only parameters so dart2js can see to drop them.
+ @pragma('dart2js:noInline')
static String _message(String message_str, String locale, String name,
List<Object> args, String meaning) {
return messageLookup.lookupMessage(
@@ -278,6 +283,7 @@
///
/// For an explanation of plurals and the [zero], [one], [two], [few], [many]
/// categories see http://cldr.unicode.org/index/cldr-spec/plural-rules
+ @pragma('dart2js:tryInline')
static String plural(num howMany,
{String zero,
String one,
@@ -309,6 +315,7 @@
meaning: meaning);
}
+ @pragma('dart2js:noInline')
static String _plural(num howMany,
{String zero,
String one,
@@ -414,6 +421,7 @@
}
/// Format a message differently depending on [targetGender].
+ @pragma('dart2js:tryInline')
static String gender(String targetGender,
{String female,
String male,
@@ -437,6 +445,7 @@
meaning: meaning);
}
+ @pragma('dart2js:noInline')
static String _gender(String targetGender,
{String female,
String male,
@@ -488,6 +497,7 @@
/// can't actually identify if something is an enum or not.
///
/// The first argument in [args] must correspond to the [choice] Object.
+ @pragma('dart2js:tryInline')
static String select(Object choice, Map<Object, String> cases,
{String desc,
Map<String, Object> examples,
@@ -500,6 +510,7 @@
locale: locale, name: name, args: args, meaning: meaning);
}
+ @pragma('dart2js:noInline')
static String _select(Object choice, Map<Object, String> cases,
{String locale, String name, List<Object> args, String meaning}) {
// Look up our translation, but pass in a null message so we don't have to