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

Side by Side Diff: xfa/fde/css/fde_cssdatatable.cpp

Issue 1990363003: Use std::unordered_map for CFDE_CSSStyleSheet::m_StringCache (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fde/css/fde_cssdatatable.h ('k') | xfa/fde/css/fde_cssdeclaration.h » ('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 "xfa/fde/css/fde_cssdatatable.h" 7 #include "xfa/fde/css/fde_cssdatatable.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fgas/crt/fgas_algorithm.h" 10 #include "xfa/fgas/crt/fgas_algorithm.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 {0xF6EFFF31, 0xff008000}, 550 {0xF6EFFF31, 0xff008000},
551 }; 551 };
552 static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = { 552 static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = {
553 {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC}, 553 {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC},
554 {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D}, 554 {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D},
555 }; 555 };
556 FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) { 556 FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) {
557 return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo) 557 return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo)
558 : NULL; 558 : NULL;
559 } 559 }
560 FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName( 560 const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByName(
561 const CFX_WideStringC& wsName) { 561 const CFX_WideStringC& wsName) {
562 ASSERT(!wsName.IsEmpty()); 562 ASSERT(!wsName.IsEmpty());
563 uint32_t dwHash = FX_HashCode_GetW(wsName, true); 563 uint32_t dwHash = FX_HashCode_GetW(wsName, true);
564 int32_t iEnd = FDE_CSSPROPERTY_MAX - 1; 564 int32_t iEnd = FDE_CSSPROPERTY_MAX - 1;
565 int32_t iMid, iStart = 0; 565 int32_t iMid, iStart = 0;
566 uint32_t dwMid; 566 uint32_t dwMid;
567 do { 567 do {
568 iMid = (iStart + iEnd) / 2; 568 iMid = (iStart + iEnd) / 2;
569 dwMid = g_FDE_CSSProperties[iMid].dwHash; 569 dwMid = g_FDE_CSSProperties[iMid].dwHash;
570 if (dwHash == dwMid) { 570 if (dwHash == dwMid) {
571 return g_FDE_CSSProperties + iMid; 571 return g_FDE_CSSProperties + iMid;
572 } else if (dwHash > dwMid) { 572 } else if (dwHash > dwMid) {
573 iStart = iMid + 1; 573 iStart = iMid + 1;
574 } else { 574 } else {
575 iEnd = iMid - 1; 575 iEnd = iMid - 1;
576 } 576 }
577 } while (iStart <= iEnd); 577 } while (iStart <= iEnd);
578 return NULL; 578 return NULL;
579 } 579 }
580 FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) { 580 const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
581 return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL; 581 return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL;
582 } 582 }
583 FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName( 583 const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByName(
584 const CFX_WideStringC& wsName) { 584 const CFX_WideStringC& wsName) {
585 ASSERT(!wsName.IsEmpty()); 585 ASSERT(!wsName.IsEmpty());
586 uint32_t dwHash = FX_HashCode_GetW(wsName, true); 586 uint32_t dwHash = FX_HashCode_GetW(wsName, true);
587 int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1; 587 int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1;
588 int32_t iMid, iStart = 0; 588 int32_t iMid, iStart = 0;
589 uint32_t dwMid; 589 uint32_t dwMid;
590 do { 590 do {
591 iMid = (iStart + iEnd) / 2; 591 iMid = (iStart + iEnd) / 2;
592 dwMid = g_FDE_CSSPropertyValues[iMid].dwHash; 592 dwMid = g_FDE_CSSPropertyValues[iMid].dwHash;
593 if (dwHash == dwMid) { 593 if (dwHash == dwMid) {
594 return g_FDE_CSSPropertyValues + iMid; 594 return g_FDE_CSSPropertyValues + iMid;
595 } else if (dwHash > dwMid) { 595 } else if (dwHash > dwMid) {
596 iStart = iMid + 1; 596 iStart = iMid + 1;
597 } else { 597 } else {
598 iEnd = iMid - 1; 598 iEnd = iMid - 1;
599 } 599 }
600 } while (iStart <= iEnd); 600 } while (iStart <= iEnd);
601 return NULL; 601 return NULL;
602 } 602 }
603 FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( 603 const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByEnum(
604 FDE_CSSPROPERTYVALUE eName) { 604 FDE_CSSPROPERTYVALUE eName) {
605 return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName) 605 return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName)
606 : NULL; 606 : NULL;
607 } 607 }
608 FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName( 608 FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(
609 const CFX_WideStringC& wsName) { 609 const CFX_WideStringC& wsName) {
610 ASSERT(!wsName.IsEmpty()); 610 ASSERT(!wsName.IsEmpty());
611 uint16_t wHash = FX_HashCode_GetW(wsName, true); 611 uint16_t wHash = FX_HashCode_GetW(wsName, true);
612 int32_t iEnd = 612 int32_t iEnd =
613 sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1; 613 sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 880 }
881 while (iBracketCount > 0 && m_pCur < m_pEnd) { 881 while (iBracketCount > 0 && m_pCur < m_pEnd) {
882 if (*m_pCur == ')') { 882 if (*m_pCur == ')') {
883 iBracketCount--; 883 iBracketCount--;
884 } 884 }
885 m_pCur++; 885 m_pCur++;
886 } 886 }
887 } 887 }
888 return m_pCur - pStart; 888 return m_pCur - pStart;
889 } 889 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssdatatable.h ('k') | xfa/fde/css/fde_cssdeclaration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698