Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: third_party/WebKit/Source/platform/Decimal.cpp

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 if (adjustedExponent >= 0) { 993 if (adjustedExponent >= 0) {
994 for (int i = 0; i < coefficientLength; ++i) { 994 for (int i = 0; i < coefficientLength; ++i) {
995 builder.append(digits[i]); 995 builder.append(digits[i]);
996 if (i == adjustedExponent) 996 if (i == adjustedExponent)
997 builder.append('.'); 997 builder.append('.');
998 } 998 }
999 return builder.toString(); 999 return builder.toString();
1000 } 1000 }
1001 1001
1002 builder.appendLiteral("0."); 1002 builder.append("0.");
1003 for (int i = adjustedExponent + 1; i < 0; ++i) 1003 for (int i = adjustedExponent + 1; i < 0; ++i)
1004 builder.append('0'); 1004 builder.append('0');
1005 1005
1006 builder.append(digits); 1006 builder.append(digits);
1007 1007
1008 } else { 1008 } else {
1009 builder.append(digits[0]); 1009 builder.append(digits[0]);
1010 while (coefficientLength >= 2 && digits[coefficientLength - 1] == '0') 1010 while (coefficientLength >= 2 && digits[coefficientLength - 1] == '0')
1011 --coefficientLength; 1011 --coefficientLength;
1012 if (coefficientLength >= 2) { 1012 if (coefficientLength >= 2) {
1013 builder.append('.'); 1013 builder.append('.');
1014 for (int i = 1; i < coefficientLength; ++i) 1014 for (int i = 1; i < coefficientLength; ++i)
1015 builder.append(digits[i]); 1015 builder.append(digits[i]);
1016 } 1016 }
1017 1017
1018 if (adjustedExponent) { 1018 if (adjustedExponent) {
1019 builder.append(adjustedExponent < 0 ? "e" : "e+"); 1019 builder.append(adjustedExponent < 0 ? "e" : "e+");
1020 builder.appendNumber(adjustedExponent); 1020 builder.appendNumber(adjustedExponent);
1021 } 1021 }
1022 } 1022 }
1023 return builder.toString(); 1023 return builder.toString();
1024 } 1024 }
1025 1025
1026 Decimal Decimal::zero(Sign sign) 1026 Decimal Decimal::zero(Sign sign)
1027 { 1027 {
1028 return Decimal(EncodedData(sign, EncodedData::ClassZero)); 1028 return Decimal(EncodedData(sign, EncodedData::ClassZero));
1029 } 1029 }
1030 1030
1031 } // namespace blink 1031 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp ('k') | third_party/WebKit/Source/platform/JSONValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698