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

Side by Side Diff: fpdfsdk/javascript/JS_Value.cpp

Issue 1814233005: Make a few more const tables smaller. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: format Created 4 years, 9 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
« no previous file with comments | « core/include/fxcrt/fx_arb.h ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/JS_Value.h" 7 #include "fpdfsdk/javascript/JS_Value.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 int _DayFromYear(int y) { 646 int _DayFromYear(int y) {
647 return (int)(365 * (y - 1970.0) + FXSYS_floor((y - 1969.0) / 4) - 647 return (int)(365 * (y - 1970.0) + FXSYS_floor((y - 1969.0) / 4) -
648 FXSYS_floor((y - 1901.0) / 100) + 648 FXSYS_floor((y - 1901.0) / 100) +
649 FXSYS_floor((y - 1601.0) / 400)); 649 FXSYS_floor((y - 1601.0) / 400));
650 } 650 }
651 651
652 double _TimeFromYear(int y) { 652 double _TimeFromYear(int y) {
653 return 86400000.0 * _DayFromYear(y); 653 return 86400000.0 * _DayFromYear(y);
654 } 654 }
655 655
656 static const uint16_t daysMonth[12] = {0, 31, 59, 90, 120, 151,
657 181, 212, 243, 273, 304, 334};
658 static const uint16_t leapDaysMonth[12] = {0, 31, 60, 91, 121, 152,
659 182, 213, 244, 274, 305, 335};
660
656 double _TimeFromYearMonth(int y, int m) { 661 double _TimeFromYearMonth(int y, int m) {
657 static int daysMonth[12] = {0, 31, 59, 90, 120, 151, 662 const uint16_t* pMonth = _isLeapYear(y) ? leapDaysMonth : daysMonth;
658 181, 212, 243, 273, 304, 334};
659 static int leapDaysMonth[12] = {0, 31, 60, 91, 121, 152,
660 182, 213, 244, 274, 305, 335};
661 int* pMonth = daysMonth;
662 if (_isLeapYear(y))
663 pMonth = leapDaysMonth;
664 return _TimeFromYear(y) + ((double)pMonth[m]) * 86400000; 663 return _TimeFromYear(y) + ((double)pMonth[m]) * 86400000;
665 } 664 }
666 665
667 int _Day(double t) { 666 int _Day(double t) {
668 return (int)FXSYS_floor(t / 86400000); 667 return (int)FXSYS_floor(t / 86400000);
669 } 668 }
670 669
671 int _YearFromTime(double t) { 670 int _YearFromTime(double t) {
672 // estimate the time. 671 // estimate the time.
673 int y = 1970 + static_cast<int>(t / (365.2425 * 86400000)); 672 int y = 1970 + static_cast<int>(t / (365.2425 * 86400000));
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 for (int i = 0; i < nKeywords; ++i) { 896 for (int i = 0; i < nKeywords; ++i) {
898 const wchar_t* property = va_arg(ap, const wchar_t*); 897 const wchar_t* property = va_arg(ap, const wchar_t*);
899 v8::Local<v8::Value> v8Value = 898 v8::Local<v8::Value> v8Value =
900 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); 899 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property);
901 if (!v8Value->IsUndefined()) 900 if (!v8Value->IsUndefined())
902 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); 901 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown);
903 } 902 }
904 va_end(ap); 903 va_end(ap);
905 return result; 904 return result;
906 } 905 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_arb.h ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698