Skip to content

Commit

Permalink
fast toLower/toUpper: add slow fallback for non-English characters
Browse files Browse the repository at this point in the history
also meta note about radians
  • Loading branch information
mcmonkey4eva committed May 14, 2023
1 parent fedb49f commit 033cf71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Expand Up @@ -319,7 +319,7 @@ public static void register() {
// @attribute <QuaternionTag.axis_angle_for[<vector>]>
// @returns ElementTag(Decimal)
// @description
// Returns the angle around the specified axis vector created by this quaternion.
// Returns the angle (in radians) around the specified axis vector created by this quaternion.
// -->
tagProcessor.registerStaticTag(ElementTag.class, ObjectTag.class, "axis_angle_for", (attribute, object, param) -> {
VectorObject axis = DenizenCore.implementation.vectorize(param, attribute.context);
Expand Down Expand Up @@ -347,7 +347,8 @@ public static void register() {
// @attribute <QuaternionTag.represented_angle>
// @returns ElementTag(Decimal)
// @description
// Returns the angle represented by this quaternion.
// Returns the angle (in radians) represented by this quaternion.
// Pairs with <@link tag QuaternionTag.represented_axis>.
// -->
tagProcessor.registerStaticTag(ElementTag.class, "represented_angle", (attribute, object) -> {
return new ElementTag(object.representedAngle());
Expand All @@ -358,6 +359,7 @@ public static void register() {
// @returns VectorObject
// @description
// Returns the axis represented by this quaternion, as a vector.
// Pairs with <@link tag QuaternionTag.represented_angle>.
// -->
tagProcessor.registerStaticTag(VectorObject.class, "represented_axis", (attribute, object) -> {
return object.representedAxis();
Expand Down
Expand Up @@ -274,7 +274,7 @@ static <T extends VectorObject> void register(Class<T> type, ObjectTagProcessor
// @returns QuaternionTag
// @group VectorObject
// @description
// Returns a quaternion that is a rotation around this vector as an axis, by the given angle input.
// Returns a quaternion that is a rotation around this vector as an axis, by the given angle input (in radians).
// -->
processor.registerTag(QuaternionTag.class, ElementTag.class, "to_axis_angle_quaternion", (attribute, object, angle) -> {
double a = angle.asDouble();
Expand Down
Expand Up @@ -544,12 +544,20 @@ public static String toUpperCase(String input) {
int len = input.length();
char c;
int first = -1;
boolean mustUseString = false;
for (int i = 0; i < len; i++) {
c = input.charAt(i);
if (c >= 'a' && c <= 'z') {
first = i;
break;
}
else if (c > 128 && Character.isLowerCase(c)) {
mustUseString = true;
break;
}
}
if (mustUseString) {
return input.toUpperCase();
}
if (first == -1) {
return input;
Expand All @@ -567,12 +575,20 @@ public static String toLowerCase(String input) {
int len = input.length();
char c;
int first = -1;
boolean mustUseString = false;
for (int i = 0; i < len; i++) {
c = input.charAt(i);
if (c >= 'A' && c <= 'Z') {
first = i;
break;
}
else if (c > 128 && Character.isUpperCase(c)) {
mustUseString = true;
break;
}
}
if (mustUseString) {
return input.toLowerCase();
}
if (first == -1) {
return input;
Expand Down

0 comments on commit 033cf71

Please sign in to comment.